This is the second part of a previously released article on WordPress customization. While in the first one we talked about making small CSS changes to tweak the design of your site, this time we’ll be going in deeper than that. The next step towards customizing your WordPress site involves the use of child themes. In this article we will be taking a look at the basics of how to create child themes, and review some of the best practices when making your own customized theme.
What Is A Child Theme?
Simply put, a child theme is a WordPress theme that inherits the functionality and design of a parent theme. The child theme can then be used to override the styles and functions of the parent without making any change to the parent theme itself. Without exception, any WordPress theme can be a parent theme.
The main advantage of child themes is that you can make just about any change to an existing theme without worrying about breaking the original design. Should something happen, you can always revert to the parent theme and start over, or simply switch themes and create a completely new child theme. This comes in handy when updating, since the parent theme will be left untouched and you will be able to install newly released features and important bugfixes. If you are going to extensively customize a WordPress theme, then child themes are always the best option.
How To Create Child Themes
Creating a new child theme is actually really simple. First off, you have to create a new folder in your themes directory that will house the child theme. For clarity, we recommend naming it something along the lines of parent-child, where parent is the name of the parent theme.
Next, all you have to do is create a new style.css file in your child theme folder. This CSS file will hold all the styles for your child theme, and will be used instead of the parent stylesheet. To keep things clean, the best way to go about this is to create a clean CSS file, and then import the parent stylesheet using the @import directive. For your covenience, here is a template you can use to quickly create a child theme:
The download only contains a single file with the following lines:
/* Theme Name: My Child Theme Description: A child theme for the [PARENT] theme. Theme URI: http://www.cpothemes.com Template: [PARENT] Author: CPOThemes Author URI: http://www.cpothemes.com Version: 1.0.0 */ @import url("../[PARENT]/style.css");
Within the file, all you need to do is replace the [PARENT] tags with the name of the folder of the parent theme. Once you have edited these tags, you can simply compress the folder into a ZIP file and upload it just like any normal theme. Your child theme should now appear in the list of available themes. You can then activate the theme, and that’s it.
Start Customizing Your Theme
From that point on, you can start adding your customized styles to the CSS stylesheet without worrying about the parent theme. You can use the same tips and advice we talked about in our previous article to add these changes to the stylesheet; the only difference is that you will be placing them into the style.css file, instead of a Custom CSS field in the Theme Options.
As you can see, child themes are really easy to set up and create. They provide a great way to customize WordPress themes without affecting the original one, and you can always revert should something go wrong. In the next article we will go over some more useful advice on how to customize certain aspects of a theme, as well as some more advanced techniques such as changing the core functionality of a theme.
Have you ever customized a WordPress theme?