描述:
通过分类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 : '';
}
发表评论
还没有评论,快来抢沙发吧!