功能:
get_tag_link()函数的功能是根据指定的标签ID返回正确的链接地址
tag name
参数:
$tag_id
(integer) (必选的) 标签的ID
默认: 无
返回值:
URL (string)
返回标签的URL地址
所在位置:
get_tag_link() 函数位于 wp-includes/category-template.php 中。
源码:
/**
* Retrieve the link to the tag.
*
* @since 2.3.0
* @see get_term_link()
*
* @param int|object $tag Tag ID or object.
* @return string Link on success, empty string if tag does not exist.
*/
function get_tag_link( $tag ) {
if ( ! is_object( $tag ) )
$tag = (int) $tag;
$tag = get_term_link( $tag, 'post_tag' );
if ( is_wp_error( $tag ) )
return '';
return $tag;
}
示例:
echo get_tag_link( $tag );//返回标签ID为5的链接地址
相关函数:
感觉本站内容不错,读后有收获?小额赞助
还可以分享文章给好友: