Sandeep Kumar Mishra
Sandeep Kumar Mishra writes about WordPress and Artificial Intelligence, offering tips and guides to help you master your website and stay updated with the latest tech trends.
At this point, the required hidden fields and nonces have already been output.
To use the edit_form_top action, first you have to register it using add_action. You can write this code into the functions.php of your activated theme or in a custom WordPress Plugin.
In the below live example, we have defined a function weplugins_execute_on_edit_form_top_event which takes 1 parameter and we registered it using add_action. The first parameter edit_form_top is the name of the hook, the second parameter weplugins_execute_on_edit_form_top_event is the name of the function which needs to be called, the third parameter is the priority of calling the hook if the same hook is used multiple times and the last parameter is the number of arguments (if any) to be passed in the registered function.
Sometimes, you have to remove a registered hook, so you can use remove_action to remove the edit_form_top action.
Below the 1 parameter is required to use this hook.
This example demonstrates how to display “hello world” at the top of the edit form.
add_action( 'edit_form_top', 'weplugins_display_hello' );
function weplugins_display_hello() {
echo __( 'hello world' );
}
This example shows how to execute a custom function when the edit form top action is triggered.
function weplugins_execute_on_edit_form_top_event($post){
// Custom code to be executed when this action occurs
}
// Add the action
add_action( "edit_form_top", "weplugins_execute_on_edit_form_top_event" , 10, 1);
This example demonstrates how to remove a previously registered hook callback.
remove_action( "edit_form_top", "weplugins_execute_on_edit_form_top_event", 10, 1 );
Please make sure to provide the same callback function name, priority, and number of arguments while removing the hook callback.
If you need any customization or are having trouble using this hook, please contact us.
Trying to stay on top of it all? Get the best tools, resources and inspiration sent to your inbox every Wednesday.