功能:
wp_get_post_tags()函数功能是用获取指定文章的标签列表。
参数:
$post_id
(integer) (可选的) 文章ID
默认: 0
$args
(array) (可选的) 需要显示的标签云参数
返回值:
(array)
函数返回文章标签列表
所在位置:
wp_get_post_tags() 函数包含在 wp-includes/post.php 中。
源码:
/**
* Retrieve the tags for a post.
*
* There is only one default for this function, called 'fields' and by default
* is set to 'all'. There are other defaults that can be overridden in
* wp_get_object_terms().
*
* @since 2.3.0
*
* @param int $post_id Optional. The Post ID. Does not default to the ID of the
* global $post. Default 0.
* @param array $args Optional. Overwrite the defaults
* @return array List of post tags.
*/
function wp_get_post_tags( $post_id = 0, $args = array() ) {
return wp_get_post_terms( $post_id, 'post_tag', $args);
}
示例:
$t = wp_get_post_tags($post->ID);
print_r($t);
相关函数:
wp_get_post_terms()
感觉本站内容不错,读后有收获?小额赞助
还可以分享文章给好友: