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.
edit_form_top action
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.
Parameters
- $post : (WP_Post) Post object.
Below the 1 parameter is required to use this hook.
Live Examples
Example 1: Display Hello World
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' ); }
Example 2: Custom Function Execution
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);
Example 3: Remove a Hook Callback
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.
Contact Us
If you need any customization or are having trouble using this hook, please contact us.
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.