How to create a child theme in WordPress ?

by Yuvi - August 28, 2021

How to create a child theme in WordPress

Adding a child theme in WordPress is a very easy process and a user with little knowledge of html and php can create child theme in WordPress.

We will discuss this process step by step here.

Step 1 to create a child theme in WordPress:-

Identify the current theme for which you are looking to create a child theme. Once you know the theme, in wp-content/themes/ create a folder named parent_theme-child ( here parent_theme is the name of the main theme e.g if theme name is “Yuvi” them child theme folder name will be “yuvi-child” ).

Step 2 to create a child theme in WordPress:-

Now create two files named style.css and  functions.php in Child theme folder which we you have create.

Now add these below codes in style.css file

/*--

Theme Name: Yuvi Child
Theme URI: https://your-domain.com/yuvi-child/
Description: Yuvi Child Theme
Author: Yogiraj
Author URI: https://www.yogiraj.co.in
Template: yuvi
Version: 0.1
Tags: Best theme, full width, with sidebar widget
----*/

/*---------- You can add custom css below------------*/

In above details WordPress only requires Theme Name (name of child theme) and Template (name of parent theme), rest all details are optional.

Step 3 to create a child theme in WordPress:-

Now we need to connect parent style.css file in child theme. Add below codes in function.php file which you have created in child theme folder.

<?php
function yu_enqueue_styles() {
wp_enqueue_style( 'yu-parent-style', get_template_directory_uri() . '/style.css' );
}
add_action ( 'wp_enqueue_scripts', 'yu_enqueue_styles' );

Once you add these codes, the child theme is successfully created and ready to use. You will find it in Appearance>Themes and you can activate it.

Child theme is very useful in WordPress and very important also. It helps to customize a theme without loosing that customization on future updates. If you customize a theme without adding a child theme then you will not be able to update that theme in future, otherwise you will loose all customization done on it when you update it.

Always do all customization using a child theme and keep theme update to date. Keeping WordPress theme and plugins is very important and essential for securing the WordPress installation and keeping it safe from malware attacks and viruses.

Conclusion –

If you are thinking to customize the theme of your WordPress website then create a child theme in and make your life comfortable during future updates.

Share on: Share YogiRaj B.Ed Study Notes on twitter Share YogiRaj B.Ed Study Notes on facebook Share YogiRaj B.Ed Study Notes on WhatsApp
Latest Posts

CDMA Full Form

April 19, 2024

Table of 14

April 11, 2024

Tables 11 to 20

March 11, 2024

Tense Chart

December 22, 2023

Table of 13

December 20, 2023
Search this Blog
Categories