[Resolved] Disable excerpt on specific category page

Home Forums Support [Resolved] Disable excerpt on specific category page

Home Forums Support Disable excerpt on specific category page

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1072271
    Royal Rangers

    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’ );

    #1072336
    David
    Staff
    Customer Support
    #1072346
    Royal Rangers

    Still doesn´t work.

    #1072582
    David
    Staff
    Customer Support

    Try the snippet provided here:

    https://docs.generatepress.com/article/excerpt_length/#examples

    Change that to the relevant category conditions

    #1072866
    Royal Rangers

    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.

    #1072870
    David
    Staff
    Customer Support

    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

    #1072901
    Royal Rangers

    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.

    #1072907
    David
    Staff
    Customer Support

    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.

    #1072911
    Royal Rangers

    Its works! Thank you very much David.

    #1072922
    David
    Staff
    Customer Support

    Awesome – glad to be of help

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