We're merging with GenerateBlocks! Learn more here.

Support Forum

Please login to receive premium support.

Support for the free plugin can be found here.

Forum Replies Created

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • in reply to: Some suggestions (you might already have solutions for?) #2909
    Adam
    Participant

    Thanks Tom that works perfectly.

    This is the code I ended up with for anyone with the same problem. Add as a code snippet and set a custom field on your post page with the name ‘wpsp_excerpt’ and the value as your custom excerpt and it will display for WP Show Posts. If nothing is set it will default to the excerpt length you have set.

    if ( ! function_exists( 'wpsp_excerpt' ) ) {
    	function wpsp_excerpt( $excerpt_length )
    	{
    		global $post;
    
    		if ( get_post_meta( get_the_ID(), $key = 'wpsp_excerpt', $single = true ) ) {
    
    	        $content = get_post_meta( get_the_ID(), $key = 'wpsp_excerpt', $single = true );
    
    	    } else {
    
    	        $content = wp_trim_words( get_the_content(), $excerpt_length, apply_filters( 'wpsp_ellipses', '...' ) );
    
    	    }
    			
    			// Strip shortcodes from our content
    		$content = strip_shortcodes( $content );
    		
    		// Strip URLs from our excerpt (oembeds etc..)
    		$content = preg_replace( '~http(s)?://[^\s]*~i', '', $content );
    		
    		// Return our content
    		echo $content;
    	}
    }
    in reply to: Some suggestions (you might already have solutions for?) #2890
    Adam
    Participant

    To my great surprise, this worked! (I have no idea if this is good code or not, but seems to be working as I want!)

    function wpsp_excerpt( )
    {
    	global $post;
    	
    	$content = get_post_meta( get_the_ID(), $key = 'wpsp_excerpt', $single = true );
    	
    	echo $content;
    }

    I had to edit the functions.php file though, as it kept returning fatal error cannot redefine function when I added it to Code Snippets. Is there another way around this so that I can add the fix in Code Snippets instead of editing plugin files?

    in reply to: Some suggestions (you might already have solutions for?) #2889
    Adam
    Participant

    I’ve been trying to figure out how I might solve this. I’ve added a custom field to one of my posts page with the key being wpsp_excerpt and the value being what I want the excerpt to be. I’ve been trying to figure out how to change the wpsp_excerpt( $excerpt_length ) so that it would call the custom field key and return the value for use as the excerpt for each post, but I don’t know php at all and keep breaking my site!

    Is that something that you could do with a custom code snippet? I’m using the WP Code Snippets plugin.

    Cheers,
    Adam

    in reply to: Some suggestions (you might already have solutions for?) #2888
    Adam
    Participant

    Hi Tom, thanks 🙂

    I’ve tried that but the custom excerpt length doesn’t work when a manual excerpt has been set on the post page as far as I can tell? It just uses the manual excerpt.

    Even then, it would leave the WP Show Posts excerpt at a word length that will leave the excerpt ending at mid sentence most of the time, and that I have no control over unless I edit the content of the post to suit the excerpt. Would it be possible to have a WP Show Posts excerpt option box on each post page, that defined a specific custom excerpt for displaying with WP Show Posts?

    in reply to: Some suggestions (you might already have solutions for?) #2876
    Adam
    Participant

    Well after all that I solved my responsive columns by setting the WP Show posts columns to 2 and adding:

    @media only screen and (min-width: 800px) { .masonry-brick {
    width: 33.3%;
    }
    }

    I’m still really struggling to figure out a way to have different excerpts on WP Show Posts and the blog page though.

Viewing 5 posts - 1 through 5 (of 5 total)