get_cat_name( int $cat_id )
Retrieve the name of a category from its ID.
Description Description
Parameters Parameters
- $cat_id
-
(int) (Required) Category ID
Return Return
(string) Category name, or an empty string if category doesn't exist.
Source Source
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; }
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
Basic Example
returns the name for the category with the id ‘4’.