Do all files in child theme override the parent?

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.

2 Answers
2

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.

Leave a Comment