Uses
| Uses | Description |
|---|---|
| wp-includes/taxonomy.php: get_term() | Get all Term data from database by Term ID. |
| wp-includes/load.php: is_wp_error() | Check whether variable is a WordPress Error. |
Retrieves category name based on category ID.
(int) (Required) Category ID.
(string|WP_Error) Category name on success, WP_Error on failure.
File: wp-includes/category-template.php
function get_the_category_by_ID( $cat_ID ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
$cat_ID = (int) $cat_ID;
$category = get_term( $cat_ID );
if ( is_wp_error( $category ) ) {
return $category;
}
return ( $category ) ? $category->name : '';
} | Version | Description |
|---|---|
| 0.71 | Introduced. |
© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_the_category_by_id