get_category_link()
get_category_link( int|object $category ) 检索类别链接URL。Ret…
get_category_link( int|object $category )
检索类别链接URL。
Retrieve category link URL.
检索类别链接URL。
Retrieve category link URL.
目录锚点:#说明#参数#返回#源码#笔记
说明(Description)
另见函数 get_term_link()
参数(Parameters)
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| $category | (int | object) | 必需 | 类别ID或对象。 |
返回(Return)
(string)链接成功,如果类别不存在,则为空string。
源码(Source)
/**
* Retrieve category link URL.
*
* @since 1.0.0
* @see get_term_link()
*
* @param int|object $category Category ID or object.
* @return string Link on success, empty string if category does not exist.
*/
function get_category_link( $category ) {
if ( ! is_object( $category ) )
$category = (int) $category;
$category = get_term_link( $category, 'category' );
if ( is_wp_error( $category ) )
return '';
return $category;
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 1.0.0 | wp-includes/category-template.php:19 | 3 | 2 |
笔记(Notes)
值得记住的是,类别id是一个术语id,而不是一个术语分类id
类别链接
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。

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