wpseek.com
A WordPress-centric search engine for devs and theme authors



get_cat_name › WordPress Function

Since1.0.0
Deprecatedn/a
get_cat_name ( $cat_id )
Parameters:
  • (int) $cat_id Category ID.
    Required: Yes
Returns:
  • (string) Category name, or an empty string if the category doesn't exist.
Defined at:
Codex:

Retrieves the name of a category from its ID.



Source

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;
}