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

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

相关函数:

阿里云