An Introduction to WordPress Child Themes – Create and Customize

WordPress Child Themes

Did you hear about WordPress Child Themes and you are in confusion what is child theme and why it is so important?

Today we are going to tell you about the importance of WordPress child themes, customization and development.

What is WordPress Child Themes?

In a nutshell, WordPress child themes are the more stable option to customize your WordPress website.

A child theme inherits the functionality and styling of the parent theme. Child themes are generally developed to customize the parent theme.

It is the recommended way to customize the website theme without restricting the opportunity to update the parent theme.

For instance, if you edit the codes of the parent theme directly, you will not able to update the theme because when you update it, all the changes you made there will be lost. Hence, changes should be made via the child theme.

For example, if you are using a theme named OceanWP and need to edit the theme codes, instead of doing it directly on the theme code, make a child theme of it and do it on the child theme. If you edit the theme codes of OceanWP directly, you will lose your all changes after updating the theme.

If you are not going to update the theme in the coming future, you can directly do it on the parent theme, However, it is not the recommended method.

Make your Own Child Theme

While purchasing the premium WordPress themes, most of the packages include child theme as well. But still, some packages missing it. On that case, you need to make your own child theme. Besides that, while downloading free WordPress themes from the WordPress repository, you will get the parent theme only.

However, while downloading the child theme from the WordPress repository, both parent theme and child theme will be downloaded automatically.

  • Go to the Appearance > Themes
  • Click on Add New
  • Search theme name Drift Blog( Child theme of WordPress theme Gist)
  • Click on Install and then activate

You can see, parent theme will be downloaded automatically.

But in most of the cases, you need to make WordPress child themes manually. Here are some easy methods to make it.

Plugin Approach

This is a simple and easy method to create a child theme. You can find the Child theme generator plugin and install it. After that, you will get an option to make a child theme.

WordPress Child Themes
Screenshot of Plugin after Installing
  • At first, from your WordPress admin panel go to the Plugins
  • Next, click on Add New
  • Search the Plugin named WP Child Theme Generator
  • Install that plugin and activate it.
  • You can check the detailed documentation about using this plugin as well.

Manual Method

Do you love to play with codes? If then, you can easily make the child theme. Because, while creating a child theme, you just need two files and some lines of codes only. Here are the steps for making a child theme.

Step 1 – Create a folder for your child theme

First, in your themes folder, public_html/wp-content/themes create a folder. For example, if you are going to make a child theme for OceanWP theme, you can make a folder named oceanwp-child. But you can use any name, this is just a recommendation.

WordPress Child Themes
Folder Created for Child Theme

Step 2 – Make a new stylesheet file

Now, inside the newly created folder, create a new style.css file. This is the mandatory file for the theme.

Use your favorite editor and to edit that style.css file. Add the below code there and save this.

/*
 Theme Name:     OceanWP Child Theme
 Theme URI:      https://wordpress.org/themes/oceanwp/
 Description:    Ocean WP Child Theme Created For customizaton
 Author:         oceanwp
 Author URI:     oceanwp.org
 Template:       oceanwp
 Version:        1.0.0
 */

The important things you need to see here is the Template: oceanwp. It should be the folder name of the parent theme. Otherwise, your child theme will not work. If you are going to make the child theme for twentynineteen, the template should be twentynineteen.

WordPress Child Themes
Code Snippet of style.css file on the Sublime Editor.

Step 3 – Activate your child theme

Your child theme is now created. style.css is enough to make a child theme, however, you need to add other files for the customization.

From your admin panel, go to appearance > themes and activate your newly created child theme.

WordPress Child Themes
Install and Activate Your Child Theme

Step 4 – Add a functions.php file on the child theme

It the end, you need to make another file functions.php and put inside the child theme root folder. This file is used for advanced customization, adding new features and loading the parent themes style in the child theme.

Paste the below code snippet on the funtions.php file you just created.

<?php
 function oceanwp_child_enqueue_styles() {
     $parent_style = 'parent-style'; // This is parent theme style. 
     wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
     wp_enqueue_style( 'child-style',
     get_stylesheet_directory_uri() . '/style.css',
     array( $parent_style )
     );
 }
 add_action( 'wp_enqueue_scripts', 'oceanwp_child_enqueue_styles' );

Well, the parent styles are now inherited on the child theme. Now, you don’t need to edit the parent theme code to customize it. Do everything via the child theme.

WordPress Child Themes
Code Snippet of functions.php file on the Sublime Editor.

The child theme is now successfully created, installed and activated. Now, how to customize the child theme? Let’s discuss the possible way to customize the WordPress website with child theme.

How to override(customize) parent theme via the child theme?

As said earlier, the primary purpose of creating a child theme is to override or customize the parent theme. Then how to do that?

While overriding the parent theme via the child theme, you need to follow some guidelines on it. For example, if you want to customize the file name header.php, simply copy the file and put inside the child theme folder. And then, customize the child theme file. This is how we customize the file.

But, if the files in the parent themes are inside the folder, you need to make the same folder path on the child theme as well. For instance, if you want to customize the file which is inside the templates-part folder, you need to make the folder with the same name on the child theme and need to put the file there and customize it.

The main thing is you need to follow the same directory path on the child theme. Otherwise, the change made by you on the child theme will not be reflected.

Conclusion

WordPress child themes are the perfect tools to customize your WordPress website. We recommend you to make child theme before working on the website.

If you are not familiar with codes, you can use the plugin to make the child theme. No matters which plugin you will use but use the updated and trusted plugin while making it.

Do you have any feedback or suggestion regarding the post? Feel free to comment us below. If you need a child theme for nay particular theme and looking for help, just let us know, we will guide you to make a child theme for you as well.

OceanWP - a free Multi-Purpose WordPress theme

30% Off.
Coupon

Use the coupon code TS30 and get 30% discount on GistPro. This theme is perfect for blog, news and magazine site. 

More Less
Doesn't expire