Is there a way to replace a function by another function in a child theme? In other words, in a theme there is a function named "theme_function" and this function is called by several files inside the theme.
I would like to find, if exist, an action that replace all occurrences of "theme_function" with another function "child_function" inside the child theme. Please note that "theme_function" that I want to replace do not have the following block:

if ( !function_exists('theme_function') ) :  

because if it that case is easy to replace the theme_function with another function having the same name in functions.php

1 Answer 1


If the parent-Theme function in question isn't either pluggable (i.e. wrapped in a if( ! function_exists( $function ) ) conditional) or filterable (i.e. returns its output wrapped in a apply_filters( $filtername, $output )), then there's no easy way to override the function.

You'll have to do one of the following:

  1. Replace all template files that contain instances of the function call, and replace those calls with your own child-Theme function, in all such templates
  2. Modify the parent Theme, to delete (or make pluggable) the function in question
  • Thank you, I was hoping that there was a method to do it, but the only way is to contaminate the parent theme or to replace a lot of files containing the function call in the child theme.
    – Avionicom
    Commented Nov 20, 2012 at 20:52
  • If the parent Theme developer is amenable to patches, you could always modify the parent Theme to make the file pluggable, and then submit the change back to the developer, as a patch. Commented Nov 20, 2012 at 20:54
  • Infact! Because the best way, always, is to make the functions pluggable.
    – Avionicom
    Commented Nov 20, 2012 at 20:58
  • 3
    Actually, I prefer making my functions filterable, in almost all cases. :) Commented Nov 20, 2012 at 20:59

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.