Ever made changes to a theme and then had them overwritten when a new version became available and you had to upgrade for some reason? If that’s the case, I’m betting you never heard about child themes, or you did, but you don’t know how to create them. In this short tutorial I’ll show you how to create a WordPress child theme for your favorite theme, so you’ll never lose your work again.
If you are working within your cPanel >> File Manager, you’ll have to create a new folder under wp-content >> Themes. Name it something that makes it easy to remember, for example “twentythirteenchild” if you’re making a child theme for the Twenty Thirteen theme. If you’re working offline, you create a folder on your computer following the same principle. When you’re done, you can zip it up and upload it to your WordPress blog like you would with any other WordPress theme.
Once you have that folder ready, you will have to create two files in it. The first one will be called style.css, the other will be a functions.php file. Both are needed for a child theme where you want to be able to change the look of and add functions to the theme. You can add more files if required, like a front-page.php, or home.php, or any already existing file in the parent theme that you want to make changes too.
In the style.css file you will add the following code to start.
Theme Name: Twenty Thirteen Child
Theme URI: https://ladywp.com/
Description: Child theme for the Twenty Thirteen theme
Author: Leslie "Lady WordPress" Bogaerts
Author URI: https://ladywp.com
You can make the following changes: the theme name to one that you feel works best, the theme URI (if you plan on selling or giving away themes, you can make this the URL of the instructions for the theme), or the place that you sell it, the description, the author (your name), the author URI (a link to your main site, perhaps). The template will be the directory name of the parent theme, and the version is whatever you want to start with. Version 1.0 works always for a first version, if it’s personal use only, it doesn’t matter much anyway.
The import URL makes it so that you don’t have to repeat the whole style.css file from the parent theme. But all the changes you put in here, will override the original ones in the parent theme’s stylesheet.
The functions.php file isn’t required to get a working child theme, but I usually add it because, to be honest, when I’m working on changing a theme, I almost always have to add some functions here or there. So, if that won’t be the case for you, you don’t need to add it, otherwise, it can’t hurt to have one for future use.
In this file you can add the following to get started:
All functions you want to add will be between the opening and closing php tag.
Once you have the basics, you can start making any changes to the theme. Want an easy start with a Twenty Thirteen child theme? You can download the one I just made here.