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

I'm curious if other PHP code files besides functions.php, WP template files and style.css in a child theme actually override the same file in a parent them?

I am working with a client that has a theme with child theme support, however, there are no hooks or actions to unload for the functions that I wish to override. Looking for a clean way to perform this override whith customized code that won't be overwrote on upgrade.

share|improve this question
up vote 4 down vote accepted

It depends entirely on a) what functions and template files you're talking about, and b) how those functions are defined, or template files are called, in the Parent Theme.

If the Parent Theme uses get_template_part(), then you're golden. If the Parent Theme uses get_stylesheet_directory_uri() or STYLESHEETPATH, then you can override, with caveats. If the Parent Theme uses get_template_directory_uri() or TEMPLATEPATH, then you're going to have a difficult time.

With functions, if the Parent Theme wraps the functions in a function_exists() conditional, then you can simply override such functions by declaring them in the Child Theme. With hooks, you can simply remove_action or remove_filter.

share|improve this answer

Normally all files are "override"-able (but not the functions.php file). Rule is: child-Theme loads first, then the parent theme.

If you want to override a function inside the functions.php file, then it should be wrapped in

if ( ! function_exists('some_function_name') ) { 
    function some_function_name() { /* do stuff */ }

Else, it's not possible.

share|improve this answer

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.