函数原型
get_category_link( int|object $category ): string
函数描述
Retrieves category link URL.
是否弃用
未弃用
函数参数
-
$category
int|object
Required - Category ID or object.
函数返回值
string Link on success, empty string if category does not exist.
函数位置
File: wp-includes/category-template.php.
函数源码
function get_category_link( $category ) {
if ( ! is_object( $category ) ) {
$category = (int) $category;
}
$category = get_term_link( $category );
if ( is_wp_error( $category ) ) {
return '';
}
return $category;
}
源码链接
变更日志
| Version | Description |
|---|---|
| 1.0.0 | Introduced. |

