钩子文档

page_attributes_meta_box_template

💡 云策文档标注

概述

page_attributes_meta_box_template 是一个 WordPress 动作钩子,在页面属性元框的模板部分标签后立即触发,用于在模板选择时执行自定义操作。

关键要点

  • 这是一个动作钩子,允许开发者在页面模板选择后添加自定义功能。
  • 钩子传递两个参数:$template(当前文章使用的模板字符串或 false)和 $post(当前文章对象)。
  • 钩子从 WordPress 4.4.0 版本开始引入。

代码示例

do_action( 'page_attributes_meta_box_template', $template, $post );

注意事项

  • 钩子仅在页面属性元框的模板部分内触发,适用于页面文章类型。
  • 相关函数 page_attributes_meta_box() 用于显示页面属性表单字段。

📄 原文内容

Fires immediately after the label inside the ‘Template’ section of the ‘Page Attributes’ meta box.

Parameters

$templatestring|false
The template used for the current post.
$postWP_Post
The current post.

Source

do_action( 'page_attributes_meta_box_template', $template, $post );

Changelog

Version Description
4.4.0 Introduced.