钩子文档

wp_before_include_template

💡 云策文档标注

概述

wp_before_include_template 是一个 WordPress 动作钩子,在包含模板文件之前立即触发,允许开发者在模板加载前执行自定义代码。

关键要点

  • 这是一个动作钩子,使用 do_action() 调用,参数为 $template(模板路径字符串)。
  • 在 WordPress 6.9.0 版本中引入,用于在模板包含前提供钩入点。
  • 主要用途包括修改模板路径、添加前置逻辑或调试模板加载过程。

代码示例

do_action( 'wp_before_include_template', $template );

📄 原文内容

Fires immediately before including the template.

Parameters

$templatestring
The path of the template about to be included.

Source

do_action( 'wp_before_include_template', $template );

Changelog

Version Description
6.9.0 Introduced.