Codex

Function Reference/is category

Contents

Description

This Conditional Tag checks if a Category archive page is being displayed. This is a boolean function, meaning it returns either TRUE or FALSE.

Usage

<?php is_category($category); ?>

Parameters

$category
(integer) (optional) Category ID, Category Title or Category Slug
Default: None

Return Values

(boolean) 
True on success, false on failure.

Examples

is_category();
// When any Category archive page is being displayed.

is_category('9');
// When the archive page for Category 9 is being displayed.

is_category('Stinky Cheeses');
// When the archive page for the Category with Name "Stinky Cheeses" is being displayed.

is_category('blue-cheese');
// When the archive page for the Category with Category Slug "blue-cheese" is being displayed.

is_category(array(9,'blue-cheese','Stinky Cheeses'));
// Returns true when the category of posts being displayed is either term_ID 9, or slug "blue-cheese", or name "Stinky Cheeses". Note: the array ability was added at Version 2.5.

Notes

Change Log

Since: 1.5.0

Source File

is_category() is located in wp-includes/query.php.

Related

is_home(), is_front_page(), is_search(), is_404(), is_singular(), is_page(), is_attachment(), is_local_attachment(), is_single(), is_sticky(), is_archive(), is_category(), is_tag(), is_author(), is_date(), is_year(), is_month(), is_day(), is_time(), is_admin(), is_preview(), is_paged(), is_page_template(), is plugin active(), is_plugin_page(), is_new_day(), is_feed(), is_trackback(), is_comments_popup(), comments_open(), pings_open(), is_taxonomy(), is_taxonomy_hierarchical(), is_term(), is_user_logged_in(), is_blog_installed(), is_active_sidebar(), is_dynamic_sidebar(), is_active_widget(), in_the_loop(), in_category(), has_tag(), has_excerpt()