I’m currently working on WooCommerce Newsletter Generator for Hijapedia when I stumbled upon this need:

Removing all actions except some actions needed on current page.

After googling and tweaking for a while, I finally found a way:

  1. Apparently, all hooks are available on $wp_filter global variable
  2. Actions are stored in multidimensional array based on priority. Try var_dump()-ing the $wp_filter.
  3. Hook early, then loop the actions to remove_action()-ing it. Make a whitelist to prevent some actions from being removed

Here’s the essence of how to do it. I’m extracting this from the plugin I mention above:

I hope this one is useful for you 😀

One thought on “Removing All Actions Except Some Actions You Want From WordPress Action Hook

  1. […] to the previous post on removing actions from particular hook on particular page, I was doing this trick when working on WooCommerce Newsletter Generator for Hijapedia […]

Share Your Thought