- This topic has 17 replies, 3 voices, and was last updated 3 years, 11 months ago by
Leo.
-
AuthorPosts
-
June 8, 2019 at 6:02 am #923279
Carson
How can I remove entry content from category archives?
June 8, 2019 at 7:33 am #923415Leo
StaffCustomer SupportHi 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 π
June 8, 2019 at 1:54 pm #923630Carson
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?
June 8, 2019 at 2:23 pm #923640Leo
StaffCustomer SupportYou can use this filter:
https://docs.generatepress.com/article/generate_show_excerpt/Let me know if you need help with the code π
June 9, 2019 at 1:08 am #923792Carson
Thanks, I’d need help with the code too. π
June 9, 2019 at 7:45 am #924074Tom
Lead DeveloperLead DeveloperThere 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.
June 9, 2019 at 9:34 am #924165Carson
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!
June 9, 2019 at 9:40 am #924166Leo
StaffCustomer SupportUnfortunately 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/#archivesLet me know if I’m missing something π
June 9, 2019 at 11:46 am #924230Carson
But this only allows excerpts or full as options or is there another setting?
June 9, 2019 at 11:54 am #924237Leo
StaffCustomer SupportSelect excerpt and set the length to 0.
That’s basically what Tom’s code is doing.
Let me know π
June 10, 2019 at 2:26 am #924567Carson
Ah I see. And there is no way how to overwrite the more tag on some pages?
June 10, 2019 at 8:40 am #925006Leo
StaffCustomer SupportTry this:
https://generatepress.com/forums/topic/is-it-possible-to-make-gp-to-ignore-more-tag/#post-875026Adding PHP: https://docs.generatepress.com/article/adding-php/
That will do it to all pages.
June 11, 2019 at 6:19 am #925821Carson
Awesome, that worked, thanks a lot!
June 11, 2019 at 8:56 am #926097Leo
StaffCustomer SupportNo problem π
June 12, 2019 at 10:59 am #927369Carson
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.
-
AuthorPosts
- You must be logged in to reply to this topic.