描述
用于快速检索模板的路径,而不包括文件扩展名。如果文件存在,它还将使用locate_template()检查父主题。允许使用更通用的模板位置,而无需使用其他get_*_template()函数。
参数
- $type
-
(string) (必填) 不带扩展名的文件名。
- $templates
-
(string[]) (可选) 模板候选项的可选列表。
默认值: array()
返回
(string) 模板文件的完整路径。
源码
更新日志
版本 | 描述 |
---|---|
1.5.0 | 开始引入 |
使用示例
示例
可以与include()或require()一起使用以检索路径。
if ( '' !== get_query_template( '404' ) ) { include( get_query_template( '404' ) ); }
或者也可以通过
if ( '' != get_404_template() ) { include( get_404_template() ); }