WordPress主题函数get_the_category_by_ID()知识点
WordPress主题函数get_the_category_by_ID()知识点。
描述:
通过分类id获取分类所有信息
用法:
<?php get_the_category_by_ID( $cat_ID ); ?>
参数:
$cat_ID
(int) (必填) 分类ID
默认值:None
源文件:
/**
* Retrieve category name based on category ID.
*
* @since 0.71
*
* @param int $cat_ID Category ID.
* @return string|WP_Error Category name on success, WP_Error on failure.
*/
function get_the_category_by_ID( $cat_ID ) {
$cat_ID = (int) $cat_ID;
$category = get_term( $cat_ID, ‘category’ );
if ( is_wp_error( $category ) )
return $category;
return ( $category ) ? $category->name : ”;
}