wpseek.com
WordPress开发者和主题制作者的搜索引擎



get_cat_name › WordPress Function

Since1.0.0
已弃用n/a
get_cat_name ( $cat_id )
参数:
  • (int) $cat_id Category ID.
    Required: Yes
返回:
  • (string) Category name, or an empty string if the category doesn't exist.
定义在:
文档:

Retrieves the name of a category from its ID.



源码

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