post_edit_form_tag action

do_action( 'post_edit_form_tag', WP_Post $post ) 

Fires inside the post editor form tag.


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"';


  • $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 ); 




 Subscribe to our weekly newsletter below and never miss the latest updates in WordPress