钩子文档

post_edit_form_tag

💡 云策文档标注

概述

post_edit_form_tag 是一个 WordPress 动作钩子,在默认文章编辑页面的表单开始标签内触发,适用于文章、页面和自定义文章类型。

关键要点

  • 触发位置:在默认文章编辑页面的 <form> 标签内,表单开始标签的末尾和闭合括号之前。
  • 参数:接受一个 $post 参数,类型为 WP_Post 对象,表示当前编辑的文章。
  • 用途:允许开发者在表单标签中添加自定义属性,如 enctype。
  • 版本:从 WordPress 3.0.0 版本引入。

代码示例

add_action( 'post_edit_form_tag' , 'post_edit_form_tag' );

function post_edit_form_tag( ) {
    echo ' enctype="multipart/form-data"';
}

📄 原文内容

Fires inside the post editor form tag.

Parameters

$postWP_Post
Post object.

More Information

Applies to the tag for the default post edit page (which is used for pages and custom post types). It is at the end of the form start tag and before the closing bracket.

<form name="post" action="post.php" method="post" id="post"<?php do_action('post_edit_form_tag'); ?>>

Source

do_action( 'post_edit_form_tag', $post );

Changelog

Version Description
3.0.0 Introduced.

User Contributed Notes