0

I've got a Category Archive page with name category-slugb.php.

I have a sidebar with some Widget Logic that uses in_category('category-sluga').

What's odd is that on this Category Archive page (i.e. for all Posts of category-slugb.php) the in_category('category-sluga') condition is being triggered as true.

Why? Is there something I'm doing wrong here?

Basically, I do not want the sidebar that has the in_category('category-sluga') Widget Logic to appear on the category-slugb.php Category Archive Page.

Any suggestions?

0

review https://codex.wordpress.org/Function_Reference/in_category vs https://codex.wordpress.org/Function_Reference/is_category

to check for a category archive, use https://codex.wordpress.org/Function_Reference/is_category

0

in_category() is the incorrect function to use. This function checks that the current post object (which equates to the first post in the loop on an archive) is in the given category.

The function you need is is_category() which checks that the current query is for the archive of the given category.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.