WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
up vote 5 down vote accepted

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
share|improve this answer
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 Nov 20 '12 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. – Chip Bennett Nov 20 '12 at 20:54
Infact! Because the best way, always, is to make the functions pluggable. – Avionicom Nov 20 '12 at 20:58
Actually, I prefer making my functions filterable, in almost all cases. :) – Chip Bennett Nov 20 '12 at 20:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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