get_front_page_template()
云策文档标注
概述
get_front_page_template() 函数用于获取当前或父主题中首页模板文件的完整路径。它基于模板层次结构,并通过动态 Hook 进行过滤。
关键要点
- 返回首页模板文件(如 front-page.php)的完整路径字符串
- 内部调用 get_query_template() 函数,传递 'frontpage' 类型和模板数组
- 模板层次结构和路径可通过动态 Hook(如 'frontpage_template_hierarchy' 和 'frontpage_template')进行过滤
- 自 WordPress 3.0.0 版本引入
代码示例
function get_front_page_template() {
$templates = array( 'front-page.php' );
return get_query_template( 'frontpage', $templates );
}
原文内容
Retrieves path of front page template in current or parent template.
Description
The template hierarchy and template path are filterable via the ‘$type_template_hierarchy’ and ‘$type_template’ dynamic hooks, where $type is ‘frontpage’.
See also
Source
function get_front_page_template() {
$templates = array( 'front-page.php' );
return get_query_template( 'frontpage', $templates );
}
Changelog
| Version | Description |
|---|---|
| 3.0.0 | Introduced. |