get_the_tag_list()
get_the_tag_list( string $before = ”, string $sep = ”, string $after = ”, int $id )
检索格式化为字符串的文章的标记。
Retrieve the tags for a post formatted as a string.
参数(Parameters)
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
$before | (string) | 可选 | 在标记之前。 |
$sep | (string) | 可选 | 在标签之间。 |
$after | (string) | 可选 | 在标签之后。 |
$id | (int) | 可选 | 文章ID。默认为当前文章。 |
返回(Return)
(string|false|WP_Error)成功时的标记列表,如果没有条件则为false,失败时为WP|u Error。
源码(Source)
/** * Retrieve the tags for a post formatted as a string. * * @since 2.3.0 * * @param string $before Optional. Before tags. * @param string $sep Optional. Between tags. * @param string $after Optional. After tags. * @param int $id Optional. Post ID. Defaults to the current post. * @return string|false|WP_Error A list of tags on success, false if there are no terms, WP_Error on failure. */ function get_the_tag_list( $before = '', $sep = '', $after = '', $id = 0 ) { /** * Filter 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 tags. * @param string $sep String to use between the tags. * @param string $after String to use after tags. * @param int $id Post ID. */ return apply_filters( 'the_tags', get_the_term_list( $id, 'post_tag', $before, $sep, $after ), $before, $sep, $after, $id ); }
更新版本 | 源码位置 | 使用 | 被使用 |
---|---|---|---|
2.3.0 | wp-includes/category-template.php:1156 | 1 function | 3 |
笔记(Notes)
稍微复杂一点的例子
一个基本的例子
get_the_tag_list() 为WP2原创文章,链接:https://www.wp2.cn/functions/get_the_tag_list/