Child Theme – A Simple Explanation
If you have dabbled around WordPress theme tutorials and descriptions, you have probably stumbled upon the term “child theme.” In this article, we’re going to go through what this term means and what a child theme is actually for. You’ll see why it’s always a good idea to have and use a child theme and you’ll probably want to create one by yourself.
First of all, when talking about WordPress themes, it’s important to clarify that themes divide into two versions: parent and child.
A parent theme contains core templates and all the necessary functions for the theme to run properly.
A child theme is a duplicate of the parent theme and requires the parent in order to work. The main difference is that a child theme doesn’t contain all the template files and functions like the parent, but only two files – functions.php & style.css.
Functions.php is a file where you can insert additional code to extend theme functionality without changing original templates. It may be useful to know that you shouldn’t copy content from parent’s functions.php to child’s version, you should only insert additional hooks or functions.
Style.css is a file in charge of layout and elements’ appearance. This is where you will insert your CSS code. Style.css also contains information about the theme name, author, version, license etc.
Why you should use a child theme?
As you may know, WordPress themes authors release new updates every now and then to fix issues with code or update bundled assets. If you wanted to modify or extend a functionality without the child theme, you’d have to edit core template files. These files will be overwritten with the latest theme update and your changes would be lost. To avoid this, it is recommended to activate the child theme and work from there. That way, you will keep your modifications and have the latest theme version at the same time.
A child theme is useful for minor changes and simple modifications, however, if you plan to do a complete design overhaul, you should go into the original template files and modify the code there.
We hope this article managed to shed a little light on what a child theme is and what it’s used for. If you liked it, please feel free to check out some of these articles as well!