What is a WordPress Child Theme?
A WordPress child theme is a theme that inherits all styles and functions from another WordPress theme, the parent theme. And this is the place where you can make changes without getting overridden when you update your parent theme.
Why Child Themes are so important?
If you modify a theme directly and it is updated, then your modifications may be lost. For example, using the Upside WordPress theme version 1.0.0, if you have made changes to the files in Upside 1.0.0, and when you update the theme to 1.0.1, all the changes will be deleted and you have to start all over again. So it’s really convenient when we make all changes in a child theme.
How to create a Child Theme
Many of our WordPress themes, especially the recent ones, do include a child theme zip file inside the theme download package so you can use it right away without creating a new child theme. If the theme doesn’t have, read this guide from the WordPress Codex or you can follow these simple steps to create a child theme within minutes.
- Step 1:The first thing you need to do is create a new folder for your child theme (eg. “upside-child”) under the wp-content/themes folder. Look at the image below:
- Step 2: Inside the child theme folder, create a CSS file with the name style.css.
The stylesheet must begin with the following (the stylesheet header):
- Theme Name (required) = use the parent theme name + child to make it easy to identify (eg. “Upside Child”)
- Theme URI (optional) = your theme link
- Author (optional) = your name
- Author URI (optional) = your website link
- Template (required) = name of the parent theme folder (in this case, it is “upside”)
- Description (optional) = you may enter any text here
- Then you may add any additional custom CSS as you want under the @import url (“../upside/style.css”); line. If you write above the line, your website won’t inherit the functionality of the parent theme.
- Step 3: Create a functions.php file. Open up a new text file, and place the following code in the top of it:
- Step 4: Zip your child theme folder.
- You may need to re-save your menu (Appearance > Menus, or Appearance > Customize > Menus) and theme options (including background and header images) after activating the child theme.
- Do not delete or rename the parent theme folder.
- If you want to modify any file, simply copy it from the parent theme folder to the child theme folder.
- Always write CSS below the @import line.
Save that file into your child theme folder with the name functions.php.
You should now have two files in your child theme folder: your style sheet file and your functions file.
How a Child Theme works?
The ways to active a child theme is exactly the same as those for any other theme. Log in to your site’s administration panel, and go to Administration Panels > Appearance > Themes. Upload the zipped copy of your child theme to your site and activate it.