Using WordPress ‘is_category()’ PHP function

The is_category() WordPress PHP function determines whether the query is for an existing category archive page. If a specific category parameter is provided, it will also check if the query is for one of the specified categories.


is_category( $category );


if ( is_category( 'News' ) ) {
    echo 'You are browsing the News category.';


  • $category (int|string|int|string, Optional) – Category ID, name, slug, or array of such to check against. Default: ''

More information

See WordPress Developer Resources: is_category()


Check if Any Category Archive Page

if ( is_category() ) {
    echo 'You are browsing a category archive page.';

Check Specific Category by ID

if ( is_category( 9 ) ) {
    echo 'You are browsing the category with ID 9.';

Check Specific Category by Name

if ( is_category( 'Stinky Cheeses' ) ) {
    echo 'You are browsing the Stinky Cheeses category.';

Check Specific Category by Slug

if ( is_category( 'blue-cheese' ) ) {
    echo 'You are browsing the Blue Cheese category.';

Check Multiple Categories

if ( is_category( array( 9, 'blue-cheese', 'Stinky Cheeses' ) ) ) {
    echo 'You are browsing one of the specified categories.';