The post_edit_form_tag WordPress PHP action fires inside the post editor form tag, allowing you to modify the form attributes.
Usage
add_action('post_edit_form_tag', 'your_custom_function'); function your_custom_function($post) { // your custom code here }
Parameters
$post
(WP_Post) – The post object being edited.
More information
See WordPress Developer Resources: post_edit_form_tag
Examples
Add enctype attribute for file uploads
This example adds the enctype
attribute to the post editor form, allowing file uploads.
add_action('post_edit_form_tag', 'add_enctype_attribute'); function add_enctype_attribute($post) { echo ' enctype="multipart/form-data"'; }
Add custom data attribute
This example adds a custom data attribute to the post editor form.
add_action('post_edit_form_tag', 'add_custom_data_attribute'); function add_custom_data_attribute($post) { echo ' data-custom-attribute="your-value"'; }
Add novalidate attribute for disabling HTML5 validation
This example adds the novalidate
attribute to the post editor form, disabling HTML5 validation.
add_action('post_edit_form_tag', 'disable_html5_validation'); function disable_html5_validation($post) { echo ' novalidate'; }
Add autocomplete attribute to disable autofill
This example adds the autocomplete
attribute to the post editor form, disabling autofill.
add_action('post_edit_form_tag', 'disable_autocomplete'); function disable_autocomplete($post) { echo ' autocomplete="off"'; }
Add a custom class to the form
This example adds a custom class to the post editor form.
add_action('post_edit_form_tag', 'add_custom_class'); function add_custom_class($post) { echo ' class="your-custom-class"'; }