3rd parameter in add_action

Many times we ignore third parameter in add_action.
add_action( string $tag, callable $function_to_add, int $priority = 10, int $accepted_args = 1 )

If you read documentation on wordpress doc then you will found higher priority leter execution
Let us take some example

add_action('wp_head','check_action1',100);
function check_action(){
echo 'later sandeep call';
}
add_action('wp_head','check_action2',13);
function check_action2(){
echo 'first sandeep here';
}

Some day before i was dequeuing some script by wp_enqueue_script(‘handle’) . But unable for that .After debug i found that code where wp_enqueue_script(‘handle’) was written priority of that action was 99. So for remove that script i add my action priority to 100.

Leave a Reply

Your email address will not be published. Required fields are marked *