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
if ( !function_exists( 'the_category_ID' ) ) { require_once ABSPATH . WPINC . '/deprecated.php'; } // Optional. Whether to echo the output. Default true. $echo = true; // NOTICE! Understand what this does before running. $result = the_category_ID($echo);
Defined (1)
The function is defined in the following location(s).
- /wp-includes/deprecated.php
- function the_category_ID($echo = true) {
- _deprecated_function( __FUNCTION__, '0.71', 'get_the_category()' );
- // Grab the first cat in the list.
- $categories = get_the_category();
- $cat = $categories[0]->term_id;
- if ( $echo )
- echo $cat;
- return $cat;
- }