Are you looking for an effective way to customizing your WordPress website’s theme and sustaining the changes even after updating the theme? The only solution to your problem is creating a child theme. The rest of the article will enlighten you regarding how to make it possible, so read ahead.

What is a Child Theme?

If you aren’t very tech-savvy or not so familiar with the WordPress themes, you must be wondering what a child theme is. Let me clarify it for you in the simplest way possible.

Imagine you have a WordPress website and want to make some changes to the existing theme to make your website more user-friendly and attractive. Now, you or a WordPress developer hired by you will work on the theme and make the required changes on it.

Finally, when your custom theme is about to go live it gets a new update, boom!! All the changes you made on your theme is gone with the new update. It must be pretty disappointing to lose all your efforts just like that. But, what is the way out of it?

Also Read: Free Responsive WordPress Themes for 2019

Don’t even think about ignoring the update as outdated software is an easy target to various security threats. Then what is the better way to deal with it?

Simply put, do not make changes on the theme. Instead, do all the customization outside of it. Now you might be wondering where?

You can create a child theme for this purpose. Hence, your main theme becomes the parent. The child theme will have the appearance and functionalities of the parent theme. Therefore you will be able to make customizations to any part of the theme and keep the changes separate from the parent theme’s files. This way you will be able to update your parent theme without losing any of the changes you made.

How WordPress Child Themes Work

Both child theme and parent theme are located in a different directory in WordPress. The child theme directory must have style.css file and function.php files in it. You are allowed to add additional customized files and file types into the child theme directory for the proper functioning of the theme.

Recommended reading: Best WordPress Photography Themes for 2019

You can give modifications to the theme’s styling to layout parameters and to even the actual coding and scripts that the child theme uses as you wish. So, when a visitor loads your website, WordPress loads the child theme first. Then the child theme inherits the missing styles and functions from the parent theme. This results in the majority of your theme’s background coding to be pulled from the parent directory but it is modified according to the child theme’s parameters before the content displays on the page.

How to Create a WordPress Child Theme

Creating a WordPress child theme is a very effortless process. You can do it in just two simple steps that only requires you to create a folder and add a file to it.

Step 1 – Create a child theme folder

At first, you will have to create a new folder in your theme’s directory by navigating to /wp-content/themes/. This directory will contain many folders representing the theme installed on your site.

Now you will have to name the child theme folder. It is a best practice to name it in the format ” Theme name-child”. For eg; if the active theme on your website is Twentynineteen, the name of the folder would be Twentynineteen-child.

Step 2 – Create a style sheet: style.css

The second step requires you to create a stylesheet file named style.css, which contains all of the CSS rules and declarations that control your theme’s appearance. This file is the only required child theme file and it must contain the below information inside it. This tells WordPress the basic info such as it is a child theme with a particular parent.

/*
Theme Name: Twenty Nineteen Child
Theme URI: https://github.com/WordPress/twentynineteen
Author: the WordPress team
Author URI: https://wordpress.org/
Description:
Requires at least: WordPress 4.9.6                                                                                  Template: Twenty Nineteen
Version: 1.3
License: GNU General Public License v2 or later
License URI: LICENSE
Text Domain: twenty-nineteen-child
Tags: one-column, flexible-header, accessibility-ready, custom-colors, custom-menu, custom-logo, editor-style,       */

In the above code, Theme name and Template are the most necessary line of codes. The theme name should be unique to your theme and Template is the name of the parent theme directory. Since the parent theme used in the example is twenty nineteen, the Template will be twenty nineteen as well. You can make necessary changes to the theme name and template as per your choice of theme.
With this step, you will be done with creating a WordPress child theme. Now if you wish to add functionalities to the child theme which are absent in the parent theme you may enqueue the parent and child theme style sheets.

Enqueue stylesheet

You can do the enqueueing by adding a wp_enqueue_scripts action and by using “wp enqueue style()” in your child theme’s function.php.

This, in turn, will require you to create a function.php file in your child theme folder. The first line of your child theme’s functions.php will be an opening PHP tag. After that, you can enqueue your parent and child theme stylesheets.

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

Once you have finished these steps you will be able to activate the child theme. Now you may peacefully make customizations to your theme without worrying about the updates.

Activating the Child Theme

Finally, it’s time to activate your child theme by logging into your WordPress website’s Administration screen and navigating to Appearance > Themes. You will be able to see the child theme listed for you to activate it. Now you may click on the child theme and activate it. You can check out Shopify V/S WooCommerce

Conclusion

Now you must have realized how easy it is to build a child theme and customize your parent theme. They are surely the best way to make desired changes to your website’s appearance. Hope you find this article useful in knowing everything about the child theme like what they are, how it works, how to create it, etc.