How to Create Child Theme in WordPress

Child Theme is a theme that inherits the functionality and styling of another theme, called the parent theme.

We need to create a folder in your theme directory

1. Create a folder and name it to “Your Theme Name” Child

2. Create a style.css file
If you want to modify your theme’s CSS, you can add CSS in the end of the style.css file and save it. These CSS lines will overwrite the parent theme CSS.

Example :

/*
Theme Name: YOUR THEME NAME
Theme URI: http://yourwebsite.com/your-theme-name/
Description: My first child theme, based on your theme name
Author: YAJTECH
Author URI: http://yajtech.com
Template: YOUR THEME NAME
Version: 1.0.0
*/

Note: Theme Name tells WordPress what the name of your theme is.
Template tells WordPress which theme it should consider as the parent theme

3. Create a function.php file
Functions.php file is where theme’s main functions are usually kept. If you need to add custom functions then you need to create functions.php file within the child theme folder and add your functions code inside it. These functions will be loaded before and in addition to the parent theme functions.

Just copy and paste this code:

<?php
/*
* Child theme functions file
*
* Your functions php code starts here just before ?>
*/
?>

You can now customize your WordPress site. If you want to make some changes to your parent theme just copy the file to the child theme.