根据类别ID检索类别名称。
原型
get_the_category_by_ID( int $cat_ID )
参数
$cat_ID
(int)
(Required)
类别ID。
返回值
(string|WP_Error)
成功时的类别名称,
源文件
路径:wp-includes/category-template.php
<?php
...
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 : '';
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/get_the_category_by_id/