WordPress获取当前文章Tag列表标签:get_the_tag_list

文 / @WordPress主题

WordPress模板标签get_the_tag_list用于获取当前标签列表,需要用在The Loop主循环中,如果在主循环之外使用,需要传递文章ID。

get_the_tag_list( string $before = '', string $sep = '', string $after = '', integer $id = 0 )

函数参数

$before

字符串值,默认为空

在链接前输出

$sep

字符串值,默认为空

在链接之间输出,用于分隔多个标签

$after

字符串值,默认为空

在链接后输出

$id

整数型,默认值:当前文章ID

指定一个文章ID,用于输出该文章的标签

函数使用示例

<?php echo get_the_tag_list('<p>标签: ', ', ', '</p>'); ?>

扩展阅读

get_the_tag_list()函数位于:wp-includes/category-template.php

相关函数:

  • get_tag()
  • get_tag_link()
  • get_tags()
  • get_the_tags()
  • is_tag()
  • the_tags()
  • single_tag_title()
  • tag_description()
  • wp_generate_tag_cloud()
  • wp_tag_cloud()
添加UTHEME为好友
扫码添加UTHEME微信为好友
· 分享WordPress相关技术文章,主题上新与优惠动态早知道。
· 微信端最大WordPress社群,限时免费入群。