Andrew Nevins
(@anevins)
WCLDN 2018 Contributor | Volunteer support
Do I make an exact copy of the parent’s php file and copy it to the child theme and edit?
Yes
Does this mean the entire php template is being overridden when I do this?
Yes
OK, just wanted to make sure I was doing that correctly (as I couldn’t imagine a way where it could work like it does with CSS overrides).
So, let’s say I make a change to footer.php (via a child theme) and in a few months the parent theme is updated. What happens if the theme update makes a change to footer.php (parent theme) that affects the functionality of the updated theme? Since my, now old, footer.php (child theme) is out-of-date, the theme could break.
What’s the best way to deal with this (aside from testing theme updates in a staging environment before rolling out to live/production)?
Do I make an exact copy of the parent’s php file and copy it to the child theme and edit?
Yes
Does this mean the entire php template is being overridden when I do this?
Yes
No! That is not the right way to do that, as then you’ll have problems as you described:
OK, just wanted to make sure I was doing that correctly (as I couldn’t imagine a way where it could work like it does with CSS overrides).
So, let’s say I make a change to footer.php (via a child theme) and in a few months the parent theme is updated. What happens if the theme update makes a change to footer.php (parent theme) that affects the functionality of the updated theme? Since my, now old, footer.php (child theme) is out-of-date, the theme could break.
What’s the best way to deal with this (aside from testing theme updates in a staging environment before rolling out to live/production)?
Usually you use something called “hooks”, you can read about them here (best I found):
http://wp.smashingmagazine.com/2011/10/07/definitive-guide-wordpress-hooks/
http://wpcandy.com/teaches/how-to-use-wordpress-hooks/
http://wp.tutsplus.com/tutorials/the-beginners-guide-to-wordpress-actions-and-filters/
http://wp.tutsplus.com/tutorials/plugins/reel-em-in-understanding-hooks-from-the-inside-out/