函数原型
get_the_tag_list( string $before = ”, string $sep = ”, string $after = ”, int $post_id ): string|false|WP_Error
函数描述
Retrieves the tags for a post formatted as a string.
是否弃用
未弃用
函数参数
-
$before
string
Optional - String to use before the tags.
Default:
'' -
$sep
string
Optional - String to use between the tags.
Default:
'' -
$after
string
Optional - String to use after the tags.
Default:
'' -
$post_id
int
Optional - Post ID. Defaults to the current post ID.
函数返回值
string|false|WP_Error A list of tags on success, false if there are no terms, WP_Error on failure.
函数位置
File: wp-includes/category-template.php.
函数源码
function get_the_tag_list( $before = '', $sep = '', $after = '', $post_id = 0 ) {
$tag_list = get_the_term_list( $post_id, 'post_tag', $before, $sep, $after );
/**
* Filters the tags list for a given post.
*
* @since 2.3.0
*
* @param string $tag_list List of tags.
* @param string $before String to use before the tags.
* @param string $sep String to use between the tags.
* @param string $after String to use after the tags.
* @param int $post_id Post ID.
*/
return apply_filters( 'the_tags', $tag_list, $before, $sep, $after, $post_id );
}
源码链接
变更日志
| Version | Description |
|---|---|
| 2.3.0 | Introduced. |

