函数原型
get_linkcatname( int $id ): string
函数描述
Gets the name of category by ID.
是否弃用
Warning: This function has been deprecated. Use get_category() instead.
函数参数
-
$id
int
Required - The category to get. If no category supplied uses 0
函数返回值
string
函数位置
File: wp-includes/deprecated.php.
函数源码
function get_linkcatname($id = 0) {
_deprecated_function( __FUNCTION__, '2.1.0', 'get_category()' );
$id = (int) $id;
if ( empty($id) )
return '';
$cats = wp_get_link_cats($id);
if ( empty($cats) || ! is_array($cats) )
return '';
$cat_id = (int) $cats[0]; // Take the first cat.
$cat = get_category($cat_id);
return $cat->name;
}
源码链接
变更日志
| Version | Description |
|---|---|
| 2.1.0 | Use get_category() |
| 0.71 | Introduced. |

