If you’ve been in the WordPress world for any period of time you are probably familiar with the term “child theme.” It has kind of become one of those scary, complex things that many try to steer clear of without actually knowing anything about it. The reality, however, is that it actually is not that scary and in fact is rather simple. But what is it, really? What does it do? Do you need it? This post will cover some of those basics questions as well as provided step by step instructions on creating one. Let’s start from the beginning…
What is a Child Theme?
A child theme is essentially a theme that fully inherits the styles and functions of another theme. This other theme is known as the parent theme (makes sense, right?). WordPress will first check to see if a template file exists in the child theme, if it does not then it will pull from the parent theme. This way you can modify only what you find necessary by making a copy of the parent themes file, adding to your child theme and then editing.
A child theme can also provide a nice place for custom css and you can use a child theme to add/edit php functions with a functions.php file.
Is a Child Theme Necessary?
If you plan to modify the theme directly through a template file or function then yes, we definitely recommend a child theme. If you make changes to your theme without using a child theme you are running the risk of losing all your added content upon updating. If, however, you plan to only make CSS changes then a child theme is not necessary. Any CSS changes can be made through the Custom CSS Box located in Theme Options (or through a plugin if you are using a non-Kadence theme that does not come packaged with a custom CSS box). Also Options selected in the “Theme Options Panel” are saved in your database not in a file. You don’t need a child theme to keep those sections when you update.
How to Create a Child Theme
- The first thing you’ll want to do is create a local folder from your desktop. Of course your folder will need a name, so we recommend using the parent name with “_child” at the end. For example “virtue_premium_child”. You’re free to name it what you like, but it is important that there are no spaces in the file name.
- The next step is to create a style sheet (style.css) for your child theme. Once created, paste the following directly into it. Just swap out the theme info for that of your own theme.
/* Theme Name: Virtue Premium Child Theme URI: http://example.com/virtue-premium-child/ Description: Virtue Premium Child Theme Author: John Doe Author URI: http://example.com Template: virtue_premium Version: 1.0.0 Tags: light, dark, two-columns, right-sidebar, responsive-layout Text Domain: virtue-child */ /* Theme customization starts here -------------------------------------------------------------- */
- Technically speaking, your style.css is the only required file. However, for most the main reason of a child theme is to edit/add functions, and to so one must create a functions.php file. That file can be empty and isn’t a template file so you shouldn’t copy it from the parent theme.
That’s it! Your child theme is done. Now all you need to do is go to into your admin and navigate to Appearance > Themes and your child theme should be there waiting to be activated! Not so bad, eh?