Site logo

[Resolved] Exclude Term in Category Archive

Home Forums Support [Resolved] Exclude Term in Category Archive

Home Forums Support Exclude Term in Category Archive

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #2419471
    Anonymous

    Hello to the US,

    I need your help again. I would like to exclude a category/term in the category archive. Is it possible to do this via a CSS instruction.

    So example categories are:

    Sports
    Business
    Germany
    headlines

    The archive shows the terms:

    headlines, sports
    Germany, headlines

    The Headlines category should not appear in the Headlines category archive in terms.

    Do you have a solution for this problem?

    Greetings from Munich

    Uwe

    #2419569
    David
    Staff
    Customer Support

    Hi there,

    try adding this PHP Snippet to your site:

    
    add_action('wp_head', function(){
        if ( is_category() ) {
            $tax = $wp_query->get_queried_object();
            $slug = $tax->name;
            echo '<style>.post-term-item.term-'.$slug.' {display: none;}';
        }
    });
    #2419606
    Anonymous

    Hi David,

    Thank you for your prompt reply. Unfortunately, I’m not a PHP professional … where do I have to enter “headlines” in the code so that this term is excluded.

    Greetings

    #2419617
    David
    Staff
    Customer Support

    That code will remove the Current Taxonomy term from the List of Terms.

    So it applies to all terms eg. if you went to the Sports Category Archive, it will hide the Sports term.

    Did you only want to remove headlines for the headline archive ?

    Sorry, i should have provided this doc, which explains:

    https://docs.generatepress.com/article/adding-php/

    #2419646
    Anonymous

    Yes,

    I will only want to remove headlines for the headline archive ?

    #2420045
    David
    Staff
    Customer Support

    Ok, try adding this CSS instead:

    
    .category-schlagzeilen .term-schlagzeilen {
        display: none;
    }
    #2420074
    Anonymous

    Hi David,

    Wonderful… it fits! Have a nice day… 🙂

    Greetings from Munich

    #2421253
    David
    Staff
    Customer Support

    Glad to be of help!

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