Mostly people ask that what is child theme? Why we create child theme? Why it is impotent? When we have to create a child theme? How we can create a child Theme? In This article we will answer these Questions that What is a child theme why we create a child theme and why it is impotent and we will cover each and every thing about child theme.

Child Theme

Child theme is wordpress theme which include the all functionality of another theme .Other theme is called its parent theme. We use child theme when we want to customize a theme without losing a these change with the upgrading of parent theme. Let me explain when we use a wordpress theme and we upgrade the color of an area or font size of text with custom code in style sheet. And when we update our theme to include the updates then style sheet will be updated then our custom changes will be misplace. To prevent this we create a child with separate style sheet for custom css and function file for php.

In style.css we write the change and when we update the theme then theme update its own style sheet and do not update the style sheet of its child theme. Than our changes exist after the updating of theme. Sometime we create a child theme with style sheet but its not work and after updates we misplace our changes. The solution is that there is a proper way to create a child theme .Child theme Always consist of two file

  • style.css
  • function.php

These two files are compulsory for child theme.(style.css) is for custo css and (function .php) is for php script.

style.css

There is a proper way to write a Style Sheet.In start of style sheet we refer the parent theme it author and it version. In the start of style sheet we write these comment lines

/*
Theme Name: Twenty Fifteen Child
Theme URI: https://example.com/twenty-fifteen-child/
Description: Twenty Fifteen Child Theme
Author: John Doe
Author URI: https://example.com
Template: twentyfifteen
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Tags: light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
Text Domain: twenty-fifteen-child
*/

In Theme Name we write the name of child theme and in Temeplate we Write the name of parent theme Directory.and in version write the version of parent theme.

function.php

The functions.php file allows you to change and add functionality and features to a WordPress website. It may contain both PHP and native WordPress functions. Plus, you are free to create your own functions.