Creating a child theme is important if you like customizing themes. This give you the ability to use a theme you like as a base and apply any changes you want without disrupting the original code. This means you can update your theme and benefit from any bug fixes and improvements without losing your modifications. Now when making child themes, you have two options. You can make them manually and with a plugin. I’ll teach you how to do both.
Creating a Child Theme Manually
The first thing you have to do is create a folder to house your child theme’s files, lets call it “template-child”. In this folder, you’ll put the files you’re customizing. The only mandatory file when creating a child theme is the style.css file. Any other files like functions.php and template files like single.php and page.php are all optional.
Now in that style.css file you created for your child theme, you need to include the same header you would use in the parent template’s style.css with a little modification.
Theme Name: Template Child
The line I made bold is very important, its what separates a child theme’s style.css file from a parent theme’s style.css file. In your child’s style.css file, that line tells WordPress the name of the parent theme. That way, the child theme inherits template files from the parent theme. Very important and useful if you’re looking to change only the CSS or a couple template files.
Now if you’re only looking to modify a few things in your parent theme’s css, you don’t have to copy and paste that into the child theme’s css file. Instead, what you can do is import the original css into your child’s css file by adding this line to the style.css file:
Now whatever CSS you want to change, you just add it below that @import command. This saves you quite a lot of time and makes the process quite simple.
If you choose to also include a functions.php file in your child theme, you don’t have to worry about adding any extra code to make sure everything works properly. The child’s functions.php file is loaded before the parent’s functions.php file, giving you an easy and effective way to modify the functionality of your theme.
If you’re done with the above steps, you’ve successfully created your first child theme. In order for your work to take effect, simply upload your child theme’s folder “template-child” to the same directory as the parent theme. Then just go to the Themes section in the admin panel and activate your child theme in order to see your work.
Creating a Child Theme with Child Themify
If you’d much prefer not getting your hands dirty in a bit of code, you can install Child Themify to create a child theme for you at the click of a button, as shown here:
This really speeds up the process and can be pretty useful if you’re in a hurry.