As we have seen in our previous post “How to display WordPress Categories on home page of website” we added Category index into our home page, and we added subcategories into Category archive page, but while doing it started showing category index onto our tag pages also, hence we now needed to distingush whether we are on tag archive page or category archive page so we can hide categories from tag pages.
WordPress provides following API’s for the same,
- is_category – Returns TRUE if we are on category archive page
- is_tag – Returns TRUE if we are on tag archive page
The related code implementation will look like as below,
You can find more details about identifying different archive pages at https://codex.wordpress.org/Function_Reference/is_archive