• I am currently using a child theme for my site for making CSS modifications (menu colour, etc.) to the site’s theme. With CSS, the child’s CSS overrides the parent’s CSS—this makes complete sense to me.

    I’m now looking to make a modification to one of the main theme’s template files (footer.php) and I’m just curious how php template files work with child themes. Do I make an exact copy of the parent’s php file and copy it to the child theme and edit? Does this mean the entire php template is being overridden when I do this?

    Thanks,
    Kristin.

Viewing 3 replies - 1 through 3 (of 3 total)
  • 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

    Thread Starter theboyk

    (@theboyk)

    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/

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘A question about Child themes & template PHP files.’ is closed to new replies.