Child Themes and Its Importance

Let`s learn about Child themes and its Importance.

A child theme is a theme that inherits the functionality and styling of another theme, called the parent theme which inherits all the functionality, features, and the code of the parent theme without making any changes to the parent theme itself. Child themes are the recommended way of modifying an existing theme without losing the ability to upgrade that theme. If you want to add any of the functionality, design, features etc on the theme, a child theme is the best way to do it. This allowed users to change the styling of the parent theme and add/modify features without losing the ability to update the parent theme. If all the changes are made from the child theme, you can upgrade the parent theme and it will not effect the changes on the site. Your changes will remain safe. But, if you edit the parent theme and add or remove the functionality, codes, CSS and made the theme update, all the changes will be lost.

Basic conditions for creating a child theme
If you are going to edit codes or add codes on the theme, it is better to use the child theme, because no any changes will be lost after the theme update too. If you are only going to add some CSS codes, it is not necessary to create a child theme. You can use an available plugin for Custom CSS. Conditions depend on how you feel comfortable in the above condition. If you are familiar with a Child theme, it will be best to create a child theme. Premium theme usually provides child theme with parent theme. At that time activate the child theme and customize the theme as per your need on the child theme.

Create your own child theme
Child theme development is an easier process. Here I am going to describe you how to create a child theme. Follow the steps and create a child theme easily within a minute.

Confirm the parent theme of which you are going to make the child theme: For example; I decided to make the child theme of the Twenty Fifteen theme. For making a child theme, the main necessary file is style.css and functions.php
Create a directory for child theme, the directory name is parent theme directory and ‘-’ and child. For example; the parent directory of twenty fifteen themes is andtwentyfifteen the directory name of its child theme is twentyfifteen-child.
Now create a style.css in a child theme directory and write the following line of code on it.

You can use the above code for the twenty fifteen child theme. If you are going to create a child theme for your own theme, copy the above similar code from parent theme style.css, located on the top of the style.css file.

Remember that, “Template” is important and never miss it. Template is the name of parent theme directory. If your parent theme folder is “business” then you have to write the “Template: business” in the child theme.

4. Now create another file functions.php on the child theme. The only required child theme file is style.css, but functions.php is necessary to enqueue styles correctly.

5. Your child theme is created. Now ZIP the directory “twentyfifteen-child” and upload the theme from Appearance > Themes > Add News > Upload > Upload the ZIP file. Make sure, in the theme list, parent theme should be available. Otherwise, the child theme will not functional.

Override templates from the child theme

If you are trying to edit the file of a parent with child theme approach, please follow the guidelines to edit.
1. Create a child theme. (You already have it)
2. Make the same directory path as parent theme on the child theme.
Example: If you want to edit the file which is inside the template-parts/content-single.php make the same directory path on a child theme, template-parts/content-single.php No need to add all the files inside the directory, just put the file which you are going to edit.
3. If you need to edit some other files, please follow the same process on 2.

Finally,

Please share your thoughts in the comment section below: