Child Themes Keep Track of Changes

When I first looked into the parent / child relationships for templates that WordPress has built into it’s framework, my first thought was “wow, that is cool” and after that soaked in was the skeptical though of “Why would I ever use this?”. In most cases I would just make a new copy of the theme before making changes to it and usually for my clients I will rename the theme to the name of the new customized theme anyway. So why would I bother linking them together? Well after working with enough WordPress sites and the bloggers that use it, I have realize the advantage of being able to keep track of what changes you have made. Let me first explain how to setup a child theme.

If you have a theme installed in your wp-content/themes/ directory, then to make a child theme you simply create a new folder in the themes directory with a new name. Copy the style.css and images folder to the new child theme. The important thing that we are keeping separate are the PHP files. There may be other folders that contain images or media files that you may need for your theme. Copy all that over because anything in the theme that links to the bloginfo(’template_url’) will need to be located within the child theme, because that is the template url. In most cases the images and style.css are the only changes a user needs to make to customize the theme. Although if other changes need to be made, we simply copy over the relevant files and make the changes we need. For example, most themes incorporate a header graphic that will need to be changed by the end user to include their logo in the design. This would normally all be in the header.php file, so we would just make a copy of it into the child theme and make the appropriate changes.

Then we need to specify in the header of the style.css file that we have a parent to this template. You can do so by typing “Template: parent-template”, where parent-template is the directory location for the parent template. ie wp-content/themes/parent-template/

That alone will give you a new theme to choose from in the WordPress back end and through the built in WordPress Theme Editor you can now start making the changes to the theme. And because we are making changes through the child theme it is clear what files we are touching and what changes have been made to the theme. Keeping track of the changes like this will avoid misunderstandings with clients about what changes have been made and how the original theme they purchased works.

Child themes will also be more useful as theme developers become more aware of there purposes. If designers will avoid hard coding text into the themes and utilize more widget ready areas on their sits, then the benefits of child themes become more meaningful. On more complicated themes with more built in custom PHP code, the ability to separate the graphic elements from the more complex code will also be a benefit to the end user. If they want to tinker with style they won’t be in a position to break a line of code that will cause the entire site to go down.

Comments are closed.

-->