How to create wordpress child theme

Sharing is caring!

Do you want to create a WordPress Child theme? As a beginner, you might find it a bit difficult but after reading this article you will be able to create child theme very easily. In this article, you will get to know What is a child theme, Why it is important and How To Create WordPress Child Themes easily (With or without plugin).

What is a child theme?

As the name suggests child theme is directly related to its parent. WordPress child themes inherit all of the features & design elements from its parent theme. It helps you to fully customize your WordPress theme. Whatever changes you make in your child theme will not affect your base or parent theme but when you make changes in the parent theme, it will reflect in the child theme.

Why you need a WordPress child theme?

Whenever you update your parent theme, your customized code which you have written will be deleted automatically because all the files of the theme will be updated. so it would be better to always write your customized code in a child theme.

I will give you one more example of the importance of a WordPress child theme. Suppose, if you make any coding mistake in your child theme, then it will not affect your parent theme because you can easily deactivate your child theme and then your parent theme will start working in this way it will not affect your live website. But if you will make any coding error in the parent theme then it will badly affect your complete website including the child theme. So that’s why it is always recommended that you should have a child theme where you can write your custom code without worrying so much.

There are two methods to create a WordPress child theme

  1. Create child theme from cpanel.
  2. Create child theme using WordPress plugin.

Method 1: Create child theme from cpanel

Most of the people find creating a child theme difficult from Cpanel because they are afraid that if they will do anything wrong then it can destroy their complete website. But if you will follow my article then you will easily create your WordPress child theme. So follow all the steps carefully to create a WordPress child theme via Cpanel.

Step 1: Login to Cpanel and then go to wp-content/themes directory. And here you need to create a folder for your child theme. Your child theme files will be stored inside this folder. Now create a folder and give it any name you want but it would be better if you will give a name similar to your parent theme, for example, you can give it name like yourthemename-child. On my side, my parent theme name is Shakehandsociety so I will name it Shakehandsociety-child.

creating folder for child theme

Step 2: After creating your child theme folder you need to open that folder and create a style.css file in under that folder. This file is mandatory in order to create a child theme. So just create a file and give it the name of style.css and this file will be used to write customized CSS code. Which I will show you later in this article.
create CSS file for child theme

Step 3: After creating style.css file. you need to write this code to style.css file and change it according to your theme details.
/*
Theme Name: Yourthemename Child
Template: Your parent theme name
Description: This is a child theme.
Author: Rishab Kapoor
Author URI: www.websofttutorials.com
*/

Now I will explain this above code:

Theme Name: Your child theme name. You can give it any name but always give it a meaningful name related to your parent theme name.
Template: Template is the folder name of parent theme. Please see below image to find template name of your parent theme. Template name should be correct otherwise your child theme will not work. On my side template name is shakehand society.

Note: Template name is case sensitive. So always write the exact name.
find wordpress parent theme template name

Description, author, author URI: These are optional but you can write it if you want.

Step 4: After creating your style.css file, Now you need to create another file and give it the name functions.php. And this file should also be under the same child theme folder.
create functions.php file child theme

Step 5:
<?php add_action( 'wp_enqueue_scripts', 'enqueue_child_theme_styles', PHP_INT_MAX);
function enqueue_child_theme_styles()
{
wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
} ?>

After creating a functions.php file. just open it and paste this PHP code in that file. This code is used to import parent theme styling inside the child theme. So that your child theme will inherit parent theme’s styling.

Step 6: Congratulations, you have created your child theme yourself. Now in order to activate it, just go to Appearance >> themes from your WordPress dashboard. Here you will find your newly created child theme. Just click on activate button and then your child theme will be activated.

activate wordpress child theme

Now just go to Appearance >> Editor. And here you can write your customized css code.
write code in child theme

I hope you have created your first child theme using this article. Now I will show you the second method to create a child theme using a WordPress plugin.

Method 2: Create child theme using WordPress Plugin

This method is very easy and you will be able to create your own child theme with few clicks.

So let’s begin.

Step 1: Go to Plugins >> Add New from your WordPress dashboard. Here we will use Child Theme Generator WordPress Plugin to create a child theme. You just need to search for this plugin and then just Install and activate this plugin.
install child theme generator plugin

Step 2: After activating this plugin you just need to go to Settigns >> Child-theme Gen.
how to create a wordpress child theme using plugin

Step 3: In this step you need to select your parent theme for which you want to create a child theme. So select your parent theme and then fill other fields like heading, description etc.

After filling all the details just click on Create new Child theme button. And it will automatically create your child theme.
select parent theme

Step 4: Your child theme is created. Now in this step you just need to activate it. So just select Activate child-theme option and then click on Finished button. Congratulations, your child theme is created and activated.
activate wordpress child theme

Step 5: Now go to Appearance >> themes and here you will see your newly created child theme. And if you want to add your custom code then go to Appearance >> Editor and just add your custom code here.

You have successfully created your child theme. If you want then you can delete this Child Theme Generator Plugin.

So in this article, we have used both methods to create a WordPress child theme and both methods are very easy to follow. Please give me your feedback in the comments sections and please let me know if you are facing any issue or you want me to write some other article.

Sharing is caring!

Rishab Kapoor on FacebookRishab Kapoor on LinkedinRishab Kapoor on TwitterRishab Kapoor on Youtube
Rishab Kapoor
A Blog writer, a Web developer and a passionate teacher. Teaching on YouTube from last 7 years. Like to write articles about Web designing, Web development, Digital Marketing, and Online money making techniques. If you have any question about Web technologies and your career then you can contact me via above my social media profiles.