[Resolved] Full length posts for 1 category, else excerpt only

Home Forums Support [Resolved] Full length posts for 1 category, else excerpt only

Home Forums Support Full length posts for 1 category, else excerpt only

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #710374
    arthur

    Hi I want one specific category to include the full length of the post, while others would show the excerpt.

    I found this article that tells how to do it, by altering the theme files:
    https://premium.wpmudev.org/forums/topic/want-one-category-post-show-full-content-but-others-to-show-excerpts-in-loop

    BUT, if there is a simple hook or something that will achieve the same thing, it seems it would make much more sense to just put in a few lines in functions.php in my child theme. As opposed to overriding the entire file for just one small change.

    Any thoughts on how to achieve this?

    Thanks!

    #710389
    Leo
    Staff
    Customer Support

    Hi there,

    Take a look at the first example here:
    https://docs.generatepress.com/article/generate_show_excerpt/

    The conditional tag you will need:
    https://codex.wordpress.org/Conditional_Tags#A_Category_Page

    Let me know if you need more info πŸ™‚

    #710396
    arthur

    Hey Leo, I tried this. But it doesn’t seem to be working…..

    add_filter( 'generate_show_excerpt','tu_full_post_photos' );
    function tu_full_post_search( $show_excerpt ) {
        if ( is_category('6') ) {
    		return false;
    	}
    	return $show_excerpt;
    }
    #710431
    Leo
    Staff
    Customer Support

    The function name has to match. Try this:

    add_filter( 'generate_show_excerpt','tu_full_post_photos' );
    function tu_full_post_photos( $show_excerpt ) {
        if ( is_category('6') ) {
    		return false;
    	}
    	return $show_excerpt;
    }

    Let me know πŸ™‚

    #710437
    arthur

    Oh haha I know better than that thanks for catching my mistake.

    #710442
    Leo
    Staff
    Customer Support

    No problem πŸ™‚

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