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 the name of a category from its ID.
(int) (Required) Category ID.
(string) Category name, or an empty string if the category doesn't exist.
File: wp-includes/category.php
function get_cat_name( $cat_id ) {
$cat_id = (int) $cat_id;
$category = get_term( $cat_id, 'category' );
if ( ! $category || is_wp_error( $category ) ) {
return '';
}
return $category->name;
} | Version | Description |
|---|---|
| 1.0.0 | Introduced. |
© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_cat_name