How To Create a WordPress Child Theme

Customizing your WordPress theme but want to be extremely safe? Don’t worry. We have got you covered. Go through the following article and you will be able to use WordPress child theme to customize your WordPress theme by the end of this. What WordPress child theme does is that it saves your customization in a different folder so that updating your parent theme doesn’t harm it.

What does child theme mean?

Basically, child theme is the reflection of any theme. The concept here is that no matter what changes you make in the child theme, your parent theme will not be affected but any change in the parent theme will be reflected in the child theme.

Need to use child theme

Undoubtedly using a child theme is the safest method to modify your themes. The best part of this is that even if your parent theme gets updated, your changes won’t be deleted. In case you face any kind of problem with the child theme modification you can easily delete it to get back to the parent theme.

Setting up a WordPress child theme

You can set up a WordPress child theme either manually or with the help of plugin.

One thing that you need to keep in mind is that it won’t work until your parent theme is present in the Themes page under Appearance.

Method 1: Manually creating child theme

#1: First of all, you will have to create a new folder and name it as per your wish, say ‘lotus-child’.

#2: Next you will have to create a file and then name it ‘style.css’.

#3: Now you will need to open this file that you have recently create and enter the following information into it.

/*
Theme Name:   Child Theme Name
Theme URI: http://www.example.com/
Description: Add a few lines about the child theme
Author:   Your Name
Author URI:   http://www.example.com
Template: Parent Theme Directory Name (lotus in this case)
Version:  1.0.0
@import url("../lotus/style.css");
*/

NOTE: You should type the correct Template name because it’s case sensitive.

As shown above, I have added a code to import the stylesheet of the parent theme. The name of the directory is “lotus”.

That’s what you need to add against “Template”. If you add “Lotus” instead of “lotus”, you will get a broken theme notification with no stylesheet.

All the other details can be altered according to your wish.

Once you do that, you should go to Appearance>>Themes and check if your child theme has been created or not. If it is, congrats, you can activate it for testing whether it has inherited the design of the parent theme or not.

Method 2: Using a plugin to create a child theme

You are free to use the free WordPress plugins available to do this work for you if doing this manually doesn’t appeal to you. Tons of free plugin are available there that will create child theme for you and save you from doing all this stuff manually. We are going to use the Child Theme Configurator plugin but you are free to use any of the plugins available to you.

 

#1: First of all, you need to download the Child Theme Configurator plugin.

#2: Now log in to your site and visit your dashboard.

#3: Navigate to Plugins and then the Add New option.

#4: Now you will have to upload the plugin, that you just downloaded, by clicking on the Upload Plugin option and then activate it.

#5: It is very important to make sure that the theme that you wish to make a child theme for is activated.

#6: This can be done by simply navigating to the Tool section and click on child themes.

#7: Now click on analyse button and follow the setup’s mentioned by plugin to create your child theme.

#8: Now you have to click on the ‘Create New Child Theme’ option.

Editing other template files

You have got to write the function in your child themes in case you wish to add any custom functions to it. Feel free to using your child theme to create any structural or layout changes of your parent theme.

Let us assume that you created a child theme of Lotus Theme for which you wish to change how it displays single pages. The location for single page is lotus/template-parts/content-single.php

#1:  In the child theme folder, create a content-single.php. You need to be extra cautious about the name and structure. They need to be the same as that of the parent theme so as to overwrite them.

#2: Next you need to create a new folder and the put this file in it but be extra sure about the path and make sure that it looks exactly as that of the parent theme.

#3: That’s all. In this step all you have to do is write the code of your wish in the content-single.php which will overwrite the parent file.

Caution: Make sure that the file name and folder path must be identical.

We hope you can easily create a child theme now. If you have any questions, please feel free to comment.

 

Check out the top 3 WordPress hosting services:

Was this article helpful?