Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/the category ID

This function has been deprecated since Version 0.71. That means it has been replaced by a new function or is no longer supported, and may be removed from future versions. All code that uses this function should be converted to use its replacement if one exists. See also wp-includes/deprecated.php. Use get_the_category instead.


Displays or returns the numeric ID of the category a post belongs to. This tag must be used within The Loop.

Replace With

This tag was deprecated when multiple categories were added to WordPress, and there is no one-to-one correspondence with another tag. This PHP code block provides an example for how you can replace it:

foreach((get_the_category()) as $category) { 
    echo $category->cat_ID . ' '; 
} ?>


 <?php the_category_ID$echo ); ?> 


(boolean) Display the category ID (TRUE) or return it for use in PHP (FALSE). Defaults to TRUE.


Displays a corresponding image for each category.

<img src="<?php the_category_ID(); ?>.gif" />

Change Log

  • Since: 0.71
  • Deprecated: ?
  • Replace By: none


See also index of Function Reference and index of Template Tags.