Archived topic
Exclude Term in Category Archive
7 replies · Started by Former User on November 17, 2022
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
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;}';
}
});
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
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:
Yes,
I will only want to remove headlines for the headline archive ?
Ok, try adding this CSS instead:
.category-schlagzeilen .term-schlagzeilen {
display: none;
}
Hi David,
Wonderful... it fits! Have a nice day... :-)
Greetings from Munich
Glad to be of help!