the_category_ID

Returns or prints a category ID.

Description

(int) the_category_ID( (constant) $echo = true ); 

Returns (int)

Category ID.

Parameters (1)

0. $echo — Optional. (constant) => true
Whether to echo the output. Default true.

Usage

  1. if ( !function_exists( 'the_category_ID' ) ) { 
  2. require_once ABSPATH . WPINC . '/deprecated.php'; 
  3.  
  4. // Optional. Whether to echo the output. Default true. 
  5. $echo = true; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = the_category_ID($echo); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/deprecated.php  
  1. function the_category_ID($echo = true) { 
  2. _deprecated_function( __FUNCTION__, '0.71', 'get_the_category()' ); 
  3.  
  4. // Grab the first cat in the list. 
  5. $categories = get_the_category(); 
  6. $cat = $categories[0]->term_id; 
  7.  
  8. if ( $echo ) 
  9. echo $cat; 
  10.  
  11. return $cat;