Check if its tag page or category page in WordPress

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,

[bash] <?php if (is_category()) { ?> //this is category archive page <?php } elseif (is_tag()) { ?> //this is tag archive page <?php } ?> [/bash]

You can find more details about identifying different archive pages at

Leave a Comment