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.
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 usesget_stylesheet_directory_uri()
orSTYLESHEETPATH
, then you can override, with caveats. If the Parent Theme usesget_template_directory_uri()
orTEMPLATEPATH
, 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 simplyremove_action
orremove_filter
.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
Else, it’s not possible.