函数原型
get_tag_template(): string
函数描述
Retrieves path of tag template in current or parent template.
是否弃用
未弃用
函数参数
无
函数返回值
string Full path to tag template file.
函数位置
File: wp-includes/template.php.
函数源码
function get_tag_template() {
$tag = get_queried_object();
$templates = array();
if ( ! empty( $tag->slug ) ) {
$slug_decoded = urldecode( $tag->slug );
if ( $slug_decoded !== $tag->slug ) {
$templates[] = "tag-{$slug_decoded}.php";
}
$templates[] = "tag-{$tag->slug}.php";
$templates[] = "tag-{$tag->term_id}.php";
}
$templates[] = 'tag.php';
return get_query_template( 'tag', $templates );
}
源码链接
变更日志
| Version | Description |
|---|---|
| 4.7.0 | The decoded form of tag-{slug}.php was added to the top of the template hierarchy when the tag slug contains multibyte characters. |
| 2.3.0 | Introduced. |

