How to create a Child Theme in WordPress

Make child theme WordPress

One of the most obvious reasons why I recommend WordPress is the ability to customize it the way a person wants. We get tons of free and paid themes to install on WordPress. Then we can customize it as per the need. While making changes to a theme, we can edit the code, change CSS rules, or add custom code in PHP and JS files. But the problem comes when there’s a new update to the theme. If you add a custom code to a theme and the theme gets an update in the future, updating the theme will remove all the custom changes. So, you will have to make those changes again if you want. If you do not want to lose your custom changes, it is recommended to make a child theme with custom changes.

What is a Child Theme in WordPress?

A child theme is basically a sum theme of a WordPress theme that automatically inherits all the functionality, features, and style of its parent theme. You can change add custom changes to the theme without actually affecting the code of the original theme. If in the future, you update the parent theme, it won’t affect the child theme made by you. So, making a child theme is the safest way of making changes to an existing theme.

Best Managed WordPress Hosting

WPEngine is the best and most secure managed hosting provider

Building a child theme in WordPress is really easy. It inherits all the virtual aspects of the parent theme. So, it also won’t break your website. In this article, I will explain how you can create a child theme in WordPress. I will try to write this guide in simple words.

Steps to create a Child Theme in WordPress

First of all, go to the themes folder of WordPress installation. You can either use File Manage of cPanel or FTP to access files. Themes filter can found in wp-content -> themes.

WordPress Themes Folder

Here, you will see several themes’ folders including the active theme you are using on your blog. When you are inside the themes folder, create a new directory and enter the name of your child theme. The name you give to this new directory will be used as the theme name.

WordPress child theme

Now go inside the new folder you just created. Here, create a style.css file. Now edit this file and add the following code.

/* 
Theme Name: TheWPGuide Child
Theme URI: https://thewpguides.com
Description: The WP Guides Child 
Theme Author: Deepanker Verma
Author URI: https://deepankerverma.com
Template: usethistip 
Version: 1.0.0
Text Domain: thewpguide-child
*/

Change the information in the code accordingly. Add the child theme’s name, URL, author name, and other data as per you want.

The most important field is Template because it defines the parent theme. Here, add the name of the parent theme. I have added usethistip because I was making the child theme of the WordPress theme usethistip. Replace it with the name of the theme whose child theme you want to create. After making the mentioned changes, save this file.

Now create another file in the same directory and give this file the name functions.php. In this file add the following code.

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

This is the PHP code that will include all the JS and CSS files of the parent theme in the child theme.

Now go to WordPress dashboard and then navigate to Appearance -> Themes. Here, you will now see a new Theme. This is the child theme you just created.

create a Child Theme in WordPress

Activate this theme and open your website in the new tab. You will see the same look as the parent theme.

You just created a child theme of a theme.

Now you can start customizing the child theme and all the changes will be made to your website’s look. For adding CSS files, edit the style.css file and add CSS changes that you want to do. You just need to find out what CSS class of the element is for modification and then add new riles for that CSS class in the child theme’s style.css file.

Similarly, you can adjust the theme’s PHP code as well. Different sections of the pages are handled by different PHP files. For example, if you want to make adjustments to the look of a WordPress single page, these are to be done in single.php. For this, copy the single.php file from the parent theme’s folder to the child theme’s folder. Make sure you are copying from the parent theme’s folder to the child theme’s folder. This file needs to exist in both folders. Now edit the single.php file present in the child theme’s folder to make modifications.

In the same way, you need to make a copy of the PHP file in the child theme’s folder for making any modifications. You can make changes in header.php, footer.php, index.php, or any other file you want.

Wrap Up

Making a child theme in WordPress is not complicated. If you want to make custom modifications to a WordPress theme, you can make a child theme and then add changes here. This will help you get all the future updates to the theme without losing your custom changes. If you don’t know PHP, you should hire a good developer who can do this for you. Otherwise, a single error can break your website.

If you are not sure whom to hire, you can contact me, I offer different WordPress development services at an affordable cost. I have more than 12 years of experience in WordPress development.


Deepanker Verma is an experienced WordPress developer who has been working on WordPress for more than 12 years. On TheWPGuides, he writes about WordPress, WordPress development, and WordPress plugins.


Similar Articles

0 Comments

Leave a comment

Comment policy: We love comments and appreciate the time that readers spend to share ideas and give feedback. However, all comments are manually moderated and those deemed to be spam or solely promotional will be deleted.

© 2022 The WP Guides Developed By Deepanker