Is it possible to disable a function of a parent theme?

Only under some circumstances.

  1. If the parent theme’s functions are wrapped in function_exists conditionals then you should be able to replace them. For example:

    // Parent
    if (!function_exists('p_wpse_95799')) {
      function p_wpse_95799() {
        // 
      }
    }
    

    If the child theme defines a function named p_wpse_95799 then the parent function will not be used. If this is a possibility you’d just need to define a function that does nothing, much like the above.

  2. If the function is ‘hooked’ to some filter or action then you might be able to un-hook it. There is a catch. The child theme functions.php loads first which means you may won’t be able to remove filters directly. You will have to hook them to run after the parent’s functions.php has ran. Otherwise you will be trying to remove something that has not been added. From the Codex: “It is also worth noting that you may need to prioritise the removal of the filter to a hook that occurs after the filter is added. You cannot successfully remove the filter before it has been added.” Mostly this will mean finding a hook that runs after the parent functions.php and hooking to that, possibly manipulating the third parameter of add_action or add_filter to cause your function to run late.

Those are the cases I can think of right now. Perhaps I have forgotten a case. I trust someone will point that out if I have 🙂

There is no PHP level “remove function” and if you try to define two functions with the same name you will get an error.

As I can’t see the code for the function you want to remove, I worry that you are going to break something by removing or altering it, if that is even possible. A little caution is in order.

Leave a Comment