get_the_tags()获取当前文章所属标签集合

目录

描述

Returns an array of objects, one object for each tag assigned to the post. If this function is used in The Loop, then no ID need be passed.

get_the_tags() 描述

用法

This function does not display anything; you should access the objects and then echo or otherwise use the desired member variables.

The following example displays the tag name of each tag assigned to the post (this is like using the_tags(), but without linking each tag to the tag view, and using spaces instead of commas):

get_the_tags() 用法

参数

$id

(int) (可选) Post id.

默认值: None

get_the_tags() 参数

返回值

(array) 

An array of Tag objects

get_the_tags() 返回值

示例

Show tag Images

This outputs tag images named after the term_id with the alt attribute set to name. You can also use any of the other member variables instead.

Show the First tag Name Only

Execute code based on different tag values

This code will display HTML code depending on if this post has a certain tag or tag(s). Just add as many else if statements as you require.

Function to show tags in a dropdown

This function outputs tags in a dropdown.

get_the_tags() 示例

历史

添加于 版本: 2.3.0

get_the_tags() 历史

源文件

get_the_tags() 函数的代码位于 wp-includes/category-template.php.

get_the_tags() 源文件

相关