I need to remove a function from the parent theme and replace it within the child theme.

The function is called print_meta($meta_box). The function is not pluggable and it located in a random file, not the functions.php file.

The function adds options to a metabox that shows in a page or post. I need to add more options but to do this I re-write the function from within the child theme.

I don't think I can use remove_filter() as the function is not hooked.

I tried this: print_meta($meta_box)

function remove_parent_theme_functions( $meta_box ) {
  remove_filter( 'init', 'print_meta' );
add_action( 'after_setup_theme', 'remove_parent_theme_functions' );

but I do not know what tag to use. I have tried all kinds.

Since the function is vital to setting up the metabox option, I assume that if I successfully removed the function when I use metabox I should get an error or the options should not appear.

So far I appear do matter what tag I use.

Is this even possible?

2 Answers 2


Is this even possible?

If your description is correct and ...

  1. The function is not pluggable, by which I assume you mean not wrapped in a if (!function_exists()) condition and
  2. The function is not a callback for an action or a filter and
  3. The function is not in a theme file that gets automatically substituted by the template loading system

... then you can't remove it or replace it except by editing the parent theme file where the function is defined, and then, yes, unless you replace that function with an altered but compatible version with the same name you will get errors. And edits to the parent will be overwritten when the parent is updated.

  • 1) correct, 2) correct, 3)...I tried copying the file and placing it in the child theme. It seems to load because I am not including the copied file at the child theme level but I do get the function already declared error.
    – Jason
    Commented May 30, 2013 at 4:23
  • You can't copy the function without removing the original. You can't declare two functions with the same name. That is basic PHP.
    – s_ha_dum
    Commented May 30, 2013 at 4:25
  • ya I was hoping that the child theme version would override the parent. tks
    – Jason
    Commented May 30, 2013 at 4:31

So I found a way to do it. Its not so much an answer but something you can try.

Since I could not remove the function I was targeting. I traced the function back to where it is was being called, and then to where that function was called...which happend to have an add_action.

So I filtered out that action. Which in turn filtered out the function that lead to my targeted function.

Now all three functions are filtered out. So I Added then back by giving each a new function name and once i got to my targeted function I made the necessary changes. Now form the add_action I have three new named functions and the changes I needed.

It worked it just took some careful copying.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.