get_cat_name()
最后更新于:2021-11-26 07:35:20
get_cat_name( int$cat_id)Retrieves the name of a category from its ID.
参数
- $cat_id
-
(int) (Required) Category ID.
响应
(string) Category name, or an empty string if the category doesn’t exist.
源文件
文件: gc-includes/category.php
function get_cat_name( $cat_id ) {
$cat_id = (int) $cat_id;
$category = get_term( $cat_id, 'category' );
if ( ! $category || is_gc_error( $category ) ) {
return '';
}
return $category->name;
}