So if you don’t know what an action hook is or how to remove one in the first place, then this isn’t a post for you.

Anyhoo, so as you know a function is normally hooked like this:



 add_action('init','some_function', 10); 

And to remove it you’d simply use the remove_action function making sure to match the priority argument if there is one, like so:

 remove_action('init','some_function', 10); 

Simples, but you already know this. The problem is when a theme or plugin hooks a function via a class like so:

class Some_Class {
 function __construct(){
  add_action('init', array($this, 'class_function'));
 function class_function(){
  //some code
//instantiate class
$some_class = new Some_Class;

To unhook the function now you need to first get access to the class object and then use it like so:

//get the class object
global $some_class;

remove_action('init', array($some_class,'class_function'));

Remember, if there is a priority argument to make sure that you match it like we did earlier.
That’s it! Good luck.

Photo by Luca Bravo on Unsplash