Actions

Actions allow you to add data or change how WordPress operates. Actions will run at a specific point in the execution of WordPress Core, plugins, and themes. Callback functions for Actions can perform some kind of a task, like echoing output to the user or inserting something into the database. Callback functions for an Action do not return anything back to the calling Action hook.

They provide a way for running a function at a specific point in the execution of WordPress Core, plugins, and themes.

function wporg_callback() {
    // do something
}
add_action( 'init', 'wporg_callback' );

Above code will running wporg_callbackwhen init hook running.

add_init also support to ordering running of code using thrid parameter is for priority.

add_action('init', 'aa');
add_action('init', 'bb',1); // run first than aa function

Action which running with do_action()and does'nt have second paramater we cannot do more with it.

Last updated