Archived topic
Remove Entry Content From Category Pages
17 replies · Started by Carson on June 8, 2019
How can I remove entry content from category archives?
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 :)
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?
You can use this filter:
https://docs.generatepress.com/article/generate_show_excerpt/
Let me know if you need help with the code :)
Thanks, I'd need help with the code too. :D
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.
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!
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 :)
But this only allows excerpts or full as options or is there another setting?
Select excerpt and set the length to 0.
That's basically what Tom's code is doing.
Let me know :)
Ah I see. And there is no way how to overwrite the more tag on some pages?
Try this:
https://generatepress.com/forums/topic/is-it-possible-to-make-gp-to-ignore-more-tag/#post-875026
Adding PHP: https://docs.generatepress.com/article/adding-php/
That will do it to all pages.
Awesome, that worked, thanks a lot!
No problem :)
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.