edit_form_top
云策文档标注
概述
edit_form_top 是一个 WordPress 动作钩子,在编辑表单的顶部触发,用于在编辑屏幕的标题后添加自定义内容。
关键要点
- 触发时机:在编辑表单的顶部,隐藏字段和非ce已输出后。
- 参数:$post(WP_Post 对象),表示当前编辑的帖子。
- 用途:允许开发者在编辑屏幕的标题后插入自定义代码或内容。
- 版本:自 WordPress 3.7.0 引入。
代码示例
add_action( 'edit_form_top', 'wpdocs_display_hello' );
function wpdocs_display_hello() {
echo __( 'hello world' );
}注意事项
此钩子适用于在编辑屏幕的“添加新帖子”标题后添加内容,示例中会输出“hello world”。
原文内容
Fires at the beginning of the edit form.
Description
At this point, the required hidden fields and nonces have already been output.
Parameters
$postWP_Post-
Post object.
Source
do_action( 'edit_form_top', $post );
Changelog
| Version | Description |
|---|---|
| 3.7.0 | Introduced. |
Skip to note 2 content
Istiaq Nirab
This hook for adding to the edit screen after the “Add New Post” title
Example :
add_action( 'edit_form_top', 'wpdocs_display_hello' ); function wpdocs_display_hello() { echo __( 'hello world' ); }It will be print “hello world” after edit screen title.