[Resolved] Excerpt only on masonry pages

Home Forums Support [Resolved] Excerpt only on masonry pages

Home Forums Support Excerpt only on masonry pages

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #131481
    Reuben

    Hi there,

    I’m currently using the normal blog format for the ‘post’ post type while I use the masonry for other custom post types. I wish to invoke the Excerpt view for masonry posts while the ‘post’ post type gets the full view. Is there any way to do so?

    In addition, for the excerpt view, is there a way to enable emojis? For some reason, they are being stripped out in excerpt view.

    Thank you!

    #131549
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    This is a tough one, there’s a way we can trick the post into using the more tag filter or not, but it’s not ideal.

    I need to add a filter so we can choose to use the excerpt or full content in certain situations.

    For example:

    add_filter( 'generate_more_tag', 'generate_force_excerpt' );
    function generate_force_excerpt()
    {
    	if ( 'your-post-type' == get_post_type() ) {
    		return 'false';
    	} else {
    		return 'true';
    	}
    }

    Basically, that checks to see if we’re on your post type – if we are, it will show the excerpt.

    If we’re not, it will trick the post into thinking the more tag is being used, so it will use the full content.

    Not ideal, but should work.

    #131585
    Reuben

    Hi Tom,

    I tried using this:

    add_filter( 'generate_more_tag', 'generate_force_excerpt' );
    function generate_force_excerpt()
    {
    	if ( is_post_type_archive( array( 'products', 'retailers' ) ) || is_tax( 'database' ) ) {
    		return 'true';
    	} else {
    		return 'false';
    	}
    }

    But now the full post shows on each and every post, no matter whether I have the excerpt enabled or not. Am I doing something wrong?

    Thanks for the quick help by the way ๐Ÿ™‚

    By the way, am I right to say that the excerpt stripping out Emojis is due to WordPress and not the theme?

    #131601
    Tom
    Lead Developer
    Lead Developer

    What the above code should do is if anything in your first if statement is true, it will show the full post regardless of any other setting.

    For anything that isn’t true in that statement, it should show the excerpt – is that not what’s happening?

    That’s correct – WordPress filters out any and all HTML in the excerpt function.

    There are ways to allow certain HTML in the excerpt, but it’s a little complicated: http://wordpress.stackexchange.com/questions/141125/allow-html-in-excerpt

    Bit late here now, but take a look at the above and let me know if you need clarification on anything ๐Ÿ™‚

    #131665
    Reuben

    Thanks for the quick replies!

    I tried this code

    add_filter( 'generate_more_tag', 'generate_force_excerpt' );
    function generate_force_excerpt()
    {
    
    		return 'false';
    	
    }

    But it still never shows the excerpt. Changing it to return ‘true’ does nothing as well.

    #131695
    Tom
    Lead Developer
    Lead Developer

    Changing that to true should force all posts to show the full post.

    For example, here’s a situation where the user wanted the most recent post to be full, while the others were excerpts: https://generatepress.com/forums/topic/showing-newest-post-in-full-on-index-pages/#post-127836

    Having it set to false will disable the more tag functionality, but won’t necessarily do anything else depending on the Blog Content setting you have.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.