get_search_template()
云策文档标注
概述
get_search_template() 函数用于检索搜索模板文件的完整路径,基于 WordPress 的模板层级机制。它通过调用 get_query_template() 实现,并支持动态 Hook 进行过滤。
关键要点
- 函数返回搜索模板文件的完整路径字符串。
- 基于 get_query_template('search') 实现,继承其模板层级逻辑。
- 模板层级和路径可通过动态 Hook '$type_template_hierarchy' 和 '$type_template' 过滤,其中 $type 为 'search'。
- 首次引入于 WordPress 1.5.0 版本。
代码示例
function get_search_template() {
return get_query_template( 'search' );
}
原文内容
Retrieves path of search 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 ‘search’.
See also
Source
function get_search_template() {
return get_query_template( 'search' );
}
Changelog
| Version | Description |
|---|---|
| 1.5.0 | Introduced. |