函数文档

get_index_template()

💡 云策文档标注

概述

get_index_template() 函数用于检索当前或父主题中 index 模板文件的完整路径。它基于 get_query_template() 实现,并允许通过动态 Hook 过滤模板层次结构和路径。

关键要点

  • 函数返回 index 模板文件的完整路径字符串。
  • 内部调用 get_query_template('index') 来获取模板路径。
  • 支持通过 '$type_template_hierarchy' 和 '$type_template' 动态 Hook(其中 $type 为 'index')过滤模板。
  • 首次引入于 WordPress 3.0.0 版本。

代码示例

function get_index_template() {
	return get_query_template( 'index' );
}

注意事项

此函数是 get_query_template() 的特定实现,用于 index 模板;相关函数包括 get_query_template(),位于 wp-includes/template.php 文件中。


📄 原文内容

Retrieves path of index 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 ‘index’.

See also

Return

string Full path to index template file.

Source

function get_index_template() {
	return get_query_template( 'index' );
}

Changelog

Version Description
3.0.0 Introduced.