[Resolved] Remove Entry Content From Category Pages

Home Forums Support [Resolved] Remove Entry Content From Category Pages

Home Forums Support Remove Entry Content From Category Pages

Viewing 15 posts - 1 through 15 (of 18 total)
  • Author
    Posts
  • #923279
    Carson

    How can I remove entry content from category archives?

    #923415
    Leo
    Staff
    Customer Support

    Hi there,

    So only show the titles on category archives?

    If so this CSS should help:

    .archive.category .entry-summary {
        display: none;
    }

    Adding CSS: https://docs.generatepress.com/article/adding-css/

    Let me know πŸ™‚

    #923630
    Carson

    Thanks a lot for the reply! That would work, but I’d prefer to just remove it all together instead of just not showing it. Is there a hook for that or something?

    #923640
    Leo
    Staff
    Customer Support

    You can use this filter:
    https://docs.generatepress.com/article/generate_show_excerpt/

    Let me know if you need help with the code πŸ™‚

    #923792
    Carson

    Thanks, I’d need help with the code too. πŸ˜€

    #924074
    Tom
    Lead Developer
    Lead Developer

    There isn’t really a way to remove it completely.

    What we could do is something like this:

    add_filter( 'generate_show_excerpt', function( $show ) {
        if ( is_category() ) {
            $show = true;
        }
    
        return $show;
    } );
    
    add_filter( 'excerpt_length', function( $length ) {
        if ( is_category() ) {
            $length = 0;
        }
    
        return $length;
    } );

    Then use Leo’s CSS just to hide the empty element.

    #924165
    Carson

    Is there a way to make this also work on posts where I used the “more” tag? For the others it seems to work fine.

    Also, I have set a custom page where the latest posts are shown, Is there a way to hide the excerpts there as well?

    Thanks for the great support on a Sunday!

    #924166
    Leo
    Staff
    Customer Support

    Unfortunately the more tag overwrites the normal excerpt function so the solution would be to remove the more tag.

    Also, I have set a custom page where the latest posts are shown, Is there a way to hide the excerpts there as well?

    So do you actually want to remove excerpt globally? If so it would be much easier to set it to 0 globally:
    https://docs.generatepress.com/article/blog-content-layout/#archives

    Let me know if I’m missing something πŸ™‚

    #924230
    Carson

    But this only allows excerpts or full as options or is there another setting?

    #924237
    Leo
    Staff
    Customer Support

    Select excerpt and set the length to 0.

    That’s basically what Tom’s code is doing.

    Let me know πŸ™‚

    #924567
    Carson

    Ah I see. And there is no way how to overwrite the more tag on some pages?

    #925006
    Leo
    Staff
    Customer Support
    #925821
    Carson

    Awesome, that worked, thanks a lot!

    #926097
    Leo
    Staff
    Customer Support

    No problem πŸ™‚

    #927369
    Carson

    Sorry, I ran into another issue. I am using this code now:

    add_filter( 'wp_trim_excerpt', 'db_excerpt_metabox_remove' );
    function db_excerpt_metabox_remove( $excerpt ) {
    	$output = $excerpt;
    	
    	if ( is_archive() && has_excerpt() ) {
    		$output = '';
    	}
    	
    	return $output;
    }
    
    add_filter( 'generate_show_excerpt', function( $show ) {
        if ( is_archive() ) {
            $show = true;
        }
    
        return $show;
    } );

    This seems to work fine on category pages, but doesn’t work on the custom blog page (I am not using the homepage as the blog page).

    I am mostly using custom/manual excerpts instead of the “more” tag and I want both to be hidden on any kind of archive page and the blog page.

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