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

