Child Themes have emerged as a great alternative to messy re-coding in case one wants to modify his website theme. Whereas WordPress developers not only create child theme in WordPress, but they also keep releasing the subsequent advanced versions as well to customize WordPress child theme. So, here in this tutorial for beginners, I will show you the steps how to create child theme in WordPress.

One of the most popular ways to customize a WordPress theme is to create a child theme of an already existing/installed theme. While you can quickly create WordPress theme with the best WordPress theme builder in the industry. However, a child theme in WordPress is one of the easiest ways to enhance your theme. And that too without any risk of messing up your design.

I have covered various aspects related to child theme in WordPress which are listed below in the content table. So, feel free to quickly navigate to any part of the blog through this table.

How to create Child Theme in WordPress? Tutorial for beginners

Before we move any further, I assume that you must be having a basic idea of child themes and you are clear about what is WordPress and its capabilities. Few of you might be comparatively new to WordPress and website building, therefore for such readers let us get acquainted with the basic terminology regarding Child Theme. A bit later, here at TemplateToaster WordPress Theme Generator blog, I will get into technical details too.

  • WordPress Theme:- It refers to any collection of stylesheets or scripts that contribute to the layout and structure in general. It also defines the design and display of the WordPress website. You may create it by yourself or download best WordPress themes or free WordPress themes from any reliable source.
  • Parent Theme:- If you are using a pre-defined theme designed by any author, then the very first copy of it becomes a parent theme. However, when newer versions of the same theme are subsequently released, you also need to upgrade it. Hence, what you basically update is your parent theme’s code.
  • Child Theme:- This is the sub theme that is created to prevent changes in appearance due to parent theme modifications. You can keep your custom modification’s code, custom HTML and CSS files in the child theme, it’ll override the main theme’s functionality and styling. The Child theme is created keeping in mind the capability for future modifications. It inherits the functionalities of the parent theme. To modify the existing theme, this is the safest way recommended by WordPress.

How to create Child Theme in WordPress Manually?

After going through the terminology, let us now head towards the steps to manually create a WordPress Child Theme. A child theme folder with a functions.php and style.css is required here. WordPress code snippets can be used in different ways to enhance the functionality of your website. Let us now have a look at various codes and steps involved in child theme WordPress.

 

Steps: Overview

  1. Create a child theme folder in your theme directory. The name of the child theme folder in the format, Parent name-“child” is recommended to be the best naming practice.
  2. The next thing is to create a CSS file. This will accomplish all the design-related goals with which you want to modify in your theme as per your need. I have taken the name “style.css”. The styles written in this file will control the overall look of your theme.
  3. After you have successfully created the child stylesheet, you need to enqueue(calling/embedding a file is called enqueue in WordPress) this child theme stylesheet. Using @import used to be the common method for this purpose in the past but is no more a recommended practice now. The currently used practice is including a ‘wp_enqueue_scripts action’ in the function file functions.php, which will be discussed later in more detail.
  4. Now you can add desired code to your child theme files and activate the child theme, add/edit the template files and use the function file “functions. php”. All these functions, styles and code will override the parent themes functionality. This will also be discussed in more detail in the latter part of this post.

Steps in details to create and customize WordPress child theme

Let’s get a wider idea of the important steps here and see how to exactly implement the above steps.

Step 1: How to add Code inside child theme stylesheet:

The code inside the child theme stylesheet has to be something like the format as under

/*
 Theme Name:   TemplateToaster Child
 Theme URI:    http://example.com/wordpress-theme-child/
 Description:  WordPress Child Theme
 Author:       Mike Davis
 Author URI:   http://example.com
 Template:     TemplateToaster
 Version:      1.0.1
 License:      GNU General Public License v2 or later
 License URI:  http://www.gnu.org/licenses/gpl-2.0.html
 Tags:         light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
 Text Domain:  templatetoasterchild
*/

You need to keep in mind the theme name which should be unique, besides that the field “Template”  should be named the same as the parent theme directory. I have used “TemplateToaster”. You might be working with a theme named differently, so you can change accordingly.

Step 2: Creating and working with the functions file:

As indicated earlier, it is recommended to use wp_enqueue_scripts action and use wp_enqueue_style() in your child theme’s “functions.php” file to enqueue your parent and child theme stylesheets. Thus, you need to create a functions.php file in your child theme directory. The structure of the code will be something as follows with a few parts that can be changed according to your own theme.

<?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' );
}

As you can see in the lines above, the first line contains an opening PHP tag (</php). Wait! You know what is PHP? Right? Okay. Moving ahead, the code to enqueue your parent and child theme stylesheets can be added proceeding that. A fact worth noticing in the use of “functions.php” is that unlike style.css, it over-writes the parent theme code instead of overriding it. Further, a sample code representing a pattern of editing the code in your functions.php file is as under.

<?php // Opening PHP tag - nothing should be before this, not even whitespace
// Custom Function to Include
function my_favicon_link() {
    echo <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />' . "\n";
}
add_action( 'wp_head', 'my_favicon_link' );

The above is a sample code where a custom function is created to impart additional characteristics to the theme. You can easily assume that editing the code directly into your functions.php file is the fastest and the smartest way in case you want any functional modifications to your theme. Whatever code you add to the functions.php file here will get added to the functionality got through the main PHP code.

Step 3: Activating the child theme :

When all the modifications are over and the child theme is ready, activating it becomes a cakewalk process. There are a few steps to activate it.

  1. Log in to the Admin Panel of your site.
  2. Go to Administration Screen Appearance Themes.
  3. Your child theme will be listed there and ready for activation. You can simply click on activate and Voila! See your child theme at work. You will see the modifications exactly as expected in the layout of your website.

How to create Child Theme in WordPress via Plugins?

In this portion of the article, we will get to know about another method to create a child theme with the help of plugins such as Child Theme Configurator, Child Theme Creator, etc. Here I am enlisting a few more such WordPress plugins.

  1. Child Theme Wizard
  2. One-Click Child Theme
  3. Easy Child Theme Creator
  4. Child Theme Creator
  5. Childify Me

All these plugins have a simple installation procedure just like any other WordPress plugins. Few have some specifications regarding compatibility with different WordPress versions. You can also check what WordPress theme is that with plugins if you like any other site’s theme for some reason. Whatever your preference may be, you will be able to easily find a child theme generator that will create the perfect child theme for you.

Conclusion

The two methods above to Create Child Theme WordPress has to be generally followed with additional customizations. Creating a WordPress child theme is by far one of the safest ways to modify your WordPress website template. Whenever you want to have a new look you can simply modify the code in the child instead of modifying the parent code all over again. Hence, the data on your website remains safe even if you are updating your website with an upgraded WordPress theme. Check out How to find WordPress login url?

You can read our other articles if you need to know how to change WordPress language of your theme, customizing your WordPress dashboard, etc. Let me know in the comments if you still have any confusion regarding WordPress Child Theme Creation process and I will try to help you further.

Related reading: WordPress 101

How to create WordPress custom login page?

How to create custom header in WordPress?