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 distinguish 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
Related :   How to move WordPress website from http to secure https ?

The related code implementation will look like as below,

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

You can find more details about identifying different archive pages at


Subscribe with Valid Email Id to receive updates in Inbox. ( Secured by Google FeedBurner )


Leave a Comment

Android Android Build system Android Commands Android Java Applications Application Libraries Application Stack / User Interface Bash / Shell Scripts Bluetooth driver Cloud Technologies Commands and Packages Compilation Content Management System Core Kernel C Programs Development & Build Development, Debugging and Performance Tools Development Environment Setup Django & REST Api Errors & Failures Git Hardware Platforms HTML JAVA Programs Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL Multimedia Audio, Video, Images NDK / Middleware / HAL OS Concepts PHP Programming Languages Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Source Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Web design and development Website Hosting Wordpress Yocto / Bitbake / Openembedded