WordPress函数get_cat_name()通过分类ID获取分类名称

描述:

通过分类ID获取分类名称

用法:

<?php get_cat_name( $cat_id ) ?>

参数:

$cat_id

(integer) (必填) 分类ID

默认值: None

源文件:

/**
 * Retrieve the name of a category from its ID.
 *
 * @since 1.0.0
 *
 * @param int $cat_id Category ID
 * @return string Category name, or an empty string if category doesn't exist.
 */
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;
}