get_the_category_by_ID()
get_the_category_by_ID( int $cat_ID ) 根据类别ID检索类别名称。Retr…
get_the_category_by_ID( int $cat_ID )
根据类别ID检索类别名称。
Retrieve category name based on category ID.
目录锚点:#参数#返回#源码
参数(Parameters)
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| $cat_ID | (int) | 必需 | 类别ID。 |
返回(Return)
(string|WP_Error)成功时类别名称,失败时WP_Error。
源码(Source)
/**
* 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 : '';
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 0.71 | wp-includes/category-template.php:108 | 1 function | 2 |
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。





还没有任何评论,赶紧来占个楼吧!