A WordPress-centric search engine for devs and theme authors



get_the_category_by_id ›

Since0.71
Deprecatedn/a
get_the_category_by_id ( $cat_ID )
Parameters:
  • (int) $cat_ID Category ID.
    Required: Yes
Returns:
  • (string|WP_Error) Category name on success, WP_Error on failure.
Defined at:
Codex:

Retrieve category name based on category ID.



Source

function get_the_category_by_ID( $cat_ID ) {
	$cat_ID   = (int) $cat_ID;
	$category = get_term( $cat_ID );

	if ( is_wp_error( $category ) ) {
		return $category;
	}

	return ( $category ) ? $category->name : '';
}