What Is A Child Theme in WordPress – And How To Create One?


Fiona O’Connell


2019 February 19th


When you want to customize a WordPress theme without losing the option to update it later, you can use a child theme.

The child theme function in WordPress offers you the ability to customize your site’s functionality and style, while still keeping the foundations of the parent theme in place for updates.

There are pros and cons to child themes, and learning how to create a child theme in WordPress can be difficult at first. In this guide, I’ll walk you through everything you need to know about child themes in WordPress:

What is WordPress Child Theme Used For?

A child theme in WordPress is simply a theme that clones the functionality and style of a theme from another theme, known as the parent theme. The rationale behind child themes is that many users want to make small changes to an existing theme, but also want to be able to make important updates to that theme.

Child Theme WordPress Installed Themes

Before child themes, updating a theme, for example, to fix a security bug, meant losing all of the custom code that went into the style tweaks you may have made to the theme.

Child themes allow you to apply an update when one is available for the parent theme, but without throwing away any changes you have made to the child theme. Fortunately, life isn't so difficult as it was only a few years ago. Now, let's see if a child theme is what you're looking for.

When is a Child Theme in WordPress a Good Option?

Using a child theme is the recommended way to make functional and stylistic changes to an existing theme because it doesn’t prevent you from making important updates to your custom theme.

In addition, learning to create a child theme in WordPress can greatly increase the flexibility in your choice of themes. For example, you can choose a theme that has almost all of the features that you need, and then create a child theme to add any additional features that are missing.

It is also easier and much less time consuming for many users to modify an existing theme than to create a theme from scratch. Since the parent theme provides a fully functional platform for your site already, you only need to edit the parts of the theme’s code that affect the functions and styles you want to change.

In the case that you forget to code something, your site will fall back on the parent theme’s functionality rather than leave part of your site broken.

Child theme WordPress Parent functionality codeOf course, there are occasions when it is better to design a theme from scratch or to stick with a pre-made theme than to create a child theme in WordPress.

If you are trying to add complex functions to an existing theme, you may actually be more hampered than helped by the parent theme’s code.

Using a child theme in WordPress also leaves you somewhat dependent on the parent theme’s developers, and there is always the chance that they will abandon the theme or initiate an update that breaks the functionality you have added to the child theme.

How Do You Create a Child Theme in WordPress?

1. Create a Child Theme Directory and Files

The first step to create a child theme in WordPress is to establish a new directory in your site’s themes folder for the child theme. Use an FTP client or your host’s cPanel to connect to your site, and then navigate to the ‘wp-content/themes/’ folder. Create a new folder inside this directory and give it a name, such as ‘Theme name-child’.

Child theme WordPress Create Child Directory

Within the new child theme folder you have created, you’ll now need to add the WordPress child theme ‘functions.php’ and ‘style.css’ files.

Child theme WordPress Style css

To create the WordPress child theme ‘functions.php’ file, simply add a blank text file named ‘functions.php’ to the folder.

Don’t copy any code from the parent theme’s ‘functions.php’ file into your new text file.

The WordPress child theme ‘style.css’ file is similarly created by simply adding a new text file name ‘style.css’ to the child theme’s folder.

But in this case, you also need to add a header to your ‘style.css’ file to tell WordPress which parent theme your child theme is based on.

Find the ‘style.css’ file of the parent theme under ‘wp-content/themes/parent theme’ folder and copy everything between the ‘/*’ at the top of the file and the following ‘*/’, which should include a row labeled ‘Template’ or ‘Theme Name’.

Then paste this information into your child theme’s new ‘style.css’ file, including the ‘/*’ and ‘*/’ symbols on either end.

2. Load the Child Theme in WordPress

Now that you have a child theme set up in your WordPress site, you can activate it on your site from your administration dashboard. Login to WordPress and navigate to ‘Appearance > Themes’. The child theme you added should appear in your list of installed themes. Click ‘Activate’ to turn the child theme on for your site.

3. Update the WordPress Child Theme ‘functions.php’ file

At this point, your site may have some obvious problems. The reason is that your child theme is not yet inheriting CSS style information from the parent theme. To fix this, you’ll need to add code to the ‘functions.php’ that tells WordPress to load the ‘style.css’ file from the parent theme.

Edit your ‘functions.php’ file by navigating to ‘Appearance > Editor’ and select ‘functions.php’ from the menu on the right-hand side of the page. Once the file is loaded, add the following code at the top:

add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );
function enqueue_parent_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );

Click ‘Update File’ when you have finished to save your changes. At this point, your site will be using the child theme but should look and function the same as if you were using the parent theme.

Child theme WordPress Edit functions php

How Do You Create Custom Styles and Functions?

You can create custom styles and functions by adding CSS code to the WordPress child theme ‘style.css’ file or by adding PHP code to the WordPress child theme ‘functions.php’ file. Both files can be edited from within WordPress under ‘Appearance > Editor’, or you can download the files from your site with an FTP client, modify them with a text editor, and then re-upload them to your site.

Depending on your knowledge of CSS and PHP, there are numerous examples online of code you can add to your WordPress child theme to change the look and feel of your site. That said, whenever you are editing the ‘style.css’ or ‘functions.php’ files on your child theme in WordPress, it is important to understand what styles and functions are already defined by your parent theme.

You will need to ensure that any code you add does not conflict with code present in the parent theme, or else you could end up with parts of your site not functioning correctly. It is always a good idea to create copies of your ‘style.css’ and ‘functions.php’ files before making changes to them since you can use these copies to restore your site’s functionality in case anything goes wrong with the new modifications.

WordPress Child Theme: Conclusion

WordPress child themes offer the ability to customize the style and functionality of an existing WordPress theme without losing the option to make updates to your theme.

While a child theme is often advantageous because it allows you to do less coding and to fall back on the functionality of the parent theme, it does leave you somewhat dependent on the parent theme’s developers and can limit the complexity of changes you can make.

Did this guide help answer the questions of what is a WordPress child theme and how you can create a child theme in WordPress? Let me know in the comments below!

Leave a Comment

* your email will not be displayed