In this article we’ll cover the basics of a WordPress child theme. Also covered is why using a child theme is so important if you want to customize the theme’s CSS or PHP files.
One of the beauties of WordPress is the abundance of WordPress themes which shave-off several hours of development time. These themes as good as they can be usually require a little bit of tweaking. The problem is that modifying a theme’s CSS or PHP files even slightly prevents you from updating it to a newer version in the future. If you do try to update your theme to a newer version, all of your changes will be overwritten and lost.
A WordPress child theme solves this problem. WordPress child themes are separate themes that rely on a parent theme for most of their functionality. If you are using a child theme, WordPress will first check your child theme to see if a specific functionality already exists. If it doesn’t exist, it will use the parent theme. This allows you to only add things you wish to change to your WordPress child theme and letting the parent theme handle the bulk of the functionality.
Since WordPress child themes fall back on parent themes, your child theme is essentially a changeset to an existing parent theme. This can result in extensive changes even though the child theme may only have a couple of files.
To create a WordPress child theme for your theme, do the following steps:
For this example, I will be creating a child theme for the Twenty Sixteen default theme.
- First, go to your theme directory and create a folder for your new theme. You may name it anything you’d like.
- The next step is to create a stylesheet file. This must be named style.css. Copy and paste the following code into the file you’ve just created:
Theme Name: Twenty Sixteen Child
Theme URI: http://yourwebsite.com/twentysixteen-child/
Description: XYZ Website based on Twenty Sixteen
Author: Level One
Author URI: http://levelonewebdesign.com
The two important items in the code above are the lines starting with Theme Name and Template. The theme name tells WordPress what the name of your child theme is, and this is the name displayed in the theme selector. The template tells WordPress which theme is the parent theme.