Archived topic
Disable excerpt on specific category page
9 replies · Started by Royal Rangers on November 22, 2019
I need disable excerpt for specific category on category and archive page. I try this code but excerpt is disable everywhere.
For example: category archiv - I don´t need excerpt, category press - I Need excerpt
Same rules are for category home - all posts.
function replace_content( $output) {
if (is_category('184, 110, 107, 115, 181')) {
return '' ;
}
}
add_filter( 'get_the_excerpt', 'replace_content' );
Still doesn´t work.
Try the snippet provided here:
https://docs.generatepress.com/article/excerpt_length/#examples
Change that to the relevant category conditions
Its works for one category. I need more category. I try this:
if ( is_category('184''107')) {
if ( is_category('184,107')) {
Doesn´t work.
You need to use an array - expand the code here to see how that works:
https://developer.wordpress.org/reference/functions/is_category/#user-contributed-notes
Its works!
Is possible disable excerpt in archive tag page - tag archive page? And disable only post of category which have disable excerpt on category page.
is_category() is the condition for i am viewing an archive.
Use the in_category() function instead this should remove the excerpt from those posts regardless of whether they are in the Blog or any of the archives.
Its works! Thank you very much David.
Awesome - glad to be of help