A child theme is a theme that inherits the functionality and styling of another theme, called the parent theme. Child themes are the recommended way of modifying an existing theme.
Why use a Child Theme?
Here this article describes the few reasons for importance of :child theme : .
1 : Preserving the modification
Sometime, we use the paid theme and we need to modify this paid theme, as own requirement.But when we will update our theme (When updated version will released) then our changes will lost so that’s why we will create a child theme and do all the modification on child theme so that our modification can’t be change.
2: Inherited Property
Child theme inherit all the property of parent theme.
3:Development Time Saving
Using a child theme can speed up development time.
As we know that Two necessary files is used for creating a theme . These are :
In the file : style.css : we write some commenting code. This code is readable by the WP Engine. So here is the example of commenting code of file : style.css :
* Theme Name : heycodetech
* Theme URI : http://heycodetech.com/
* Author : the heycodetech Team
* Author URI : http://heycodetech.com/
* Description: Describe about the theme
* Version : ….. Describe about the version …
* License : ….. Describe about the licence …
* License URI: ….. Describe about the licence uri …
* Tags : ….. Describe about the tags …
* Text Domain: ….. Describe about the textdomain …
Creating a child Theme :
The first step in creating a child theme is to create the child theme directory, which will be placed in wp-content/themes.In this directory, we will place the two files : index.php and functions.php : .
For making an child theme, we need to add one more attribute : Attribute Name – Template: #Parent Theme Name# : in file : style.css : . So our commenting code of file : style.css : will be :-
* Theme Name :Child Theme heycodetech 1
* Template :heycodetech
Necessary file for creating an child Theme:
For creating a child theme, we need only two file named :
1 : style.css
2 : functions.php
and this file (style.css) have only one extra attribute named : Template: #Parent Theme Name# : For more details, see the above example .
It is recommended (though not required, especially if you are making a theme for public use) that the name of your child theme directory(wp-content/themes/theme-child) is appended/added with “-child”. You will also want to make sure that there are no spaces in your child theme directory name, which may result in errors.
We can also invoke/override other template file like header.php, footer.php, single.php,page.php etc in child theme also.
Here is the Template file structure for invoking in WP .
Chile Theme Template = > Parent Theme Template
For more details, visit the WP website : https://codex.wordpress.org/Child_Themes
Share own thought.