on-internet
← Community

The difference between do_action() and add_action() in Wordpress

Stack Overflow ·

After reading multiple online posts about do_action()/add_action(), I would like to brief my understanding about them. Here I would only talk about action hooks, not about the filters. do_action() : Registers an action hook add_action() : adds a callback function to the registered hook. Now the questions are : 1> About add_action()/do_action() for existing hook : add_action( 'admin_enqueue_scripts', 'my_func'); In the above example the callback function my_func() is registered with the hook 'admin_enqueue_scripts'. Now whenever do_action('admin_enqueue_scripts') is called somewhere inside the

Comments

Sign in or sign up to comment and upvote.

No comments yet.