函数文档

get_404_template()

💡 云策文档标注

概述

get_404_template() 函数用于检索当前或父主题中的 404 模板文件路径。它基于 get_query_template() 实现,并支持通过动态钩子过滤模板层级和路径。

关键要点

  • 函数返回 404 模板文件的完整路径字符串。
  • 通过动态钩子 '404_template_hierarchy' 和 '404_template' 可过滤模板层级和路径。
  • 内部调用 get_query_template('404') 来获取模板路径。
  • 自 WordPress 1.5.0 版本引入。

代码示例

function get_404_template() {
	return get_query_template( '404' );
}

📄 原文内容

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

See also

Return

string Full path to 404 template file.

Source

function get_404_template() {
	return get_query_template( '404' );
}

Changelog

Version Description
1.5.0 Introduced.