Exciting News! Flipper Code is now WePlugins! Same commitment to excellence, brand new identity.

How to use post_edit_form_tag action in WordPress

Sandeep Kumar Mishra
Sandeep Kumar Mishra
July 5, 2022
5 minutes read
Share Via:

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



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.