This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.
post_edit_form_tag action
do_action( 'post_edit_form_tag', WP_Post $post )
Fires inside the post editor form tag.
Description
This action allows you to append code to the form tag in the default post/page editor.
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'
); ?>>
post_edit_form_tag includes the current post object as an argument. You can do something like this to restrict your custom enctype to a specific post type:function
add_action( 'post_edit_form_tag' , 'post_edit_form_tag' );
function post_edit_form_tag($post ) {
if($post->post_type === 'your_custom_post_type'){
echo ' enctype="multipart/form-data"';
}
}
Parameters
- $post : (WP_Post) Post object.
Live Example
To run the hook, copy the example below.
// run the action do_action( 'post_edit_form_tag', $post );
The following example is for adding a hook callback.
// define the post_edit_form_tag callback function action_post_edit_form_tag( $post ) { // make action magic happen here... }; // add the action add_action( 'post_edit_form_tag', 'action_post_edit_form_tag', 10, 1 );
To remove a hook callback, use the example below.
// remove the action remove_action( 'post_edit_form_tag', 'action_post_edit_form_tag', 10, 1 );
Explore the latest in WordPress
Trying to stay on top of it all? Get the best tools, resources and inspiration sent to your inbox every Wednesday.