WordPress is a giant in the CMS market (covering over 27% of the CMS market share alone). Likewise, it provides its users with the privilege to modify and customize WordPress sites to a great extent.  

Theme modification has become very important today. With the advancement of technology, people’s mindsets are changing as well. Hence, you should consider upgrading your website functionalities according to the latest trends.

Now there are almost no limitations in customizing your site using WordPress. But then again, if there is an update from the theme developer, nearly all of your customizations, apart from some minor style decoration in the CSS file, will be lost.

Plus, it is a fact that WordPress themes release regular updates to improve features and security and to conduct bugs fixes.

Thus, WordPress has a solution, ‘Child Theme.’

‘Child theme’ is a perk which you can use to apply customizations on your site, without editing the core files of the theme. Hence your site will enjoy the customizations that you applied, and at the same time, the theme can be updated without losing the customizations.

Let’s dig a little deeper on how Child Themes operate.

What Is A Child Theme?

A child theme is an extension of your parent/main theme where you can apply any types customizations, and the core files of your theme won’t be affected at all.

Here Is How A Child Theme Works

A child theme contains files with the same names as in the main theme folder (which are either copied from the main theme or created separately). Any customizations you wish to apply, you can apply the codes in these files.

When the site is loaded, the main components of the theme are loaded from the core files of the theme, but the customizations will load from the child theme files.

When you update the theme, it will replace the core files of the theme with new files, but the child theme files will remain unchanged. Thus, your website will have an updated theme, while your customizations will remain unchanged.

Are Child Themes Self Dependent?  

Child themes are an extension of your parent theme, not a separate version or a copy of the theme. It only has codes for customizations and is extended from the parent theme.

So, the answer is No. Child themes are not independent. When a website has an active child theme, it mainly loads the core files from the parent theme, the child theme simply overrides coders in certain areas that are specified for customizations.

Some Advantages Of Using A Child Theme

A Child theme works as a safeguard to your customizations. Here are few advantages you can get out of using a child theme:

  • Customizations are unchanged even if you update the main theme.

  • Core files of the parent theme and the child theme files are in two separate folders. Hence, there is no chance of altering core files even by mistake.

  • Since applying codes in a Child theme doesn’t affect the core files, it can be used to practice or test new sets of customizations.

  • You do not need to go through tons of codes and alter specific areas for customization. You simply need to apply the codes in the child theme files, and it will automatically override those specific areas of the core theme files.

Basically, a child theme allows you to apply or test customizations, without much hassle and without altering any core functionalities of a certain theme.

Now, not all themes provide a child theme automatically. But you can create one on your own.

Hence, let us learn how to create a child theme manually.

Steps To Create A Child Theme Manually

In order to create a child theme, you need to create a separate folder. And in that folder, you need to create two files, style.css and functions.php. (These are basically the files where you apply customizations).

Now let me show you how to create a child theme using an example, and guide you with the correct steps to follow. I’ll be using the theme ‘Twenty Eleven,’ a default theme by WordPress, for this example.

Step 1: Create A Child Theme Folder In wp-content/themes:

In your WordPress folder for your website, all the files for themes are in the directory wp-content > themes. Create a new folder in the same directory.

It is recommended to name it same as the name of the theme you wish to extend, and add ‘-child’ as a suffix (thus making it easier to identify which theme it is a child version of).

I named my folder ‘twentyeleven-child’.

Step 2: Create a ‘style.css’ file:

Open a text editor (I use Sublime Text Editor) and save it as ‘style.css‘ in your child theme folder. Copy and paste the following codes into this file and save it.


/*
Theme Name: Twenty Eleven Child
Theme URI: https://wordpress.org/themes/twentyeleven/
Description: https://wordpress.org
Author: C S Sultan
Author URI: https://rextheme.com
Template: twentyeleven
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: blog, one-column, two-columns, left-sidebar, right-sidebar, custom-background, custom-colors.
Text Domain: twenty-eleven-child
*/

Replace information with relevant data where required, according to the instructions below: Description: https://wordpress.org

Theme Name: It’s the name of your child theme that will be displayed in your Dashboard.

Theme URI: URL of your main theme.

Description: It describes the purpose of the child theme or what it represents.

Author: Your name

Author URI: Your website

Template: Name of the parent theme folder. **This is very important. Without this, the child theme won’t be able to detect the core files of the parent theme. Hence, the child theme won’t function.

Version: This term represents the version of the child theme you created, and it will change per modifications.

License: GNU General Public License v2 or later

License URI: http://www.gnu.org/licenses/gpl-2.0.html.

Tags: In this section, categorize your theme according to its purpose to keep track of its use

Text Domain: Set a text domain name for your child theme.

(Data collected from WordPress Codex)

Text Domain: Set a text domain name for your child theme.

(Data collected from WordPress Codex)

Step 3: Create A ‘functions.php’ File:

Open up text editor again and save it as ‘functions.php‘ in your child theme folder. Copy and paste the following codes in this file and save it. (This code will enqueue the parent and child theme style sheets).


<?php
function my_theme_enqueue_styles() {
$parent_style = ‘twentyeleven-style’; //Name it anything, but must be unique for every enqueue.
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 ),
wp_get_theme()->get(‘Version’)
);}
add_action( ‘wp_enqueue_scripts’, ‘my_theme_enqueue_styles’ );
?>

(Data collected from developer.wordpress.org)

Please note that the above codes will work only if your parent theme holds all the CSS codes in one ‘style.css’ file only.  In case there are multiple CSS files in your parent theme, you will need to specify its directory in the ‘get_template_directory‘ section of the code.

For example, if you have an ‘extra.css’ file in the parent theme which you wish to enqueue, and it is in another folder ‘Extras” in the template directory, then you need to set the code “wp_enqueue_style($parent_style, get_template_directory_uri() . ‘/Extras/extra.css’);”

Once the style.css and functions.php files are in place, your Child Theme is pretty much ready.

Step 4: Upload And Activate Your Child Theme:

Create a .zip form of your child theme folder. In my case, it is ‘twentyeleven-child.zip’.

Go to your WordPress Dashboard > Appearance > Themes and click on ‘Add New Theme‘ on the page.

Upload your child theme zip file and click on ‘Install’.

Now you can activate your child theme at Appearance > Themes and use it at your own convenience. Initially, the child theme will display the website same as the parent theme, since no customizations have been applied yet.

The next thing to do is to apply codes in style.css or functions.php for exclusive customizations, or you can use plugins and make internal changes using page builders within WordPress. Whatever customizations you make now, will be saved within your child theme only.

Conclusion:

To create a website that is credible, it is always wise to use a Child Theme when applying any customizations on your site. Hopefully, this after reading this article, you will be able to create a child theme on your own.

All the best with your website.

Meanwhile, you can also check 13 WordPress Plugins for Customer Support.