Conditional tag for all categories of a custom post type

There are a few concerns here in the registration of your custom taxonomy

  • as from the comments on your OP, this is not your code, but a client’s code. Still, taxonomy and custom post type names should never contain hyphens, just underscores to separate words

  • there are non valid arguments used like exclude_from_search and has_archive which doesn’t exists register_taxonomy

  • this is just a tip, set the query_var argument to true to make the use of working directly with the query variables available for the taxonomy

The conditional tag, is_tax()should return true on any taxonomy archive page. You can also make this tag very specific by setting its parameters.

I do believe that this is rather a logic problem than a WordPress problem. I would however first correct the problems that I have mentioned above. You should try to separate your concerns here.

I would recommend to first test all conditions separately and make sure that individualy they work, and then work from there putting everything together. I would also not mix the && and || operators, try to separate them.

One last thing to make sure of, make sure that there are no custom queries that have replaced the main query on the archive pages. Your changes won’t be applied if a custom query is used.

Leave a Comment