How to create a WordPress child theme

How to create a child theme in WordPress

If you’re new to WordPress, you might well be wondering what, exactly, a child theme is. It’s pretty straight-forward – A child theme allows you to make small changes or modifications to your website’s functionality or styling without directly editing the parent theme files.

Using child themes is the WordPress recommended way to make small changes or modifications to your theme. When using a child theme, if you update your parent theme to a newer version in the future, any changes or modifications you make will not be lost.

Fear not, creating a child theme relatively easy. Just follow the 3 easy steps below:

1. Create a folder for your child theme

There are a few ways of doing this but generally, this is done via FTP or by using the file manager in your web hosting control panel. Simply create a new folder within your theme folder in your WordPress installation eg. /wp-content/themes/

You can give the child theme folder whatever name you like, but WordPress recommends using the parent themes folder name suffixed with ‘-child’.

2. Create a style.css stylesheet file

Within the new child theme folder that you just created, we now need to create a ‘style.css’ file and add in a theme header comment in order to tell WordPress some basic information about the new child theme. WordPress recognises this header comment and uses it to register the theme and display information about the theme within the admin area.

Edit the ‘style.css’ file that you just created and add the following CSS comment in the top of the file, replacing the details with that of your own

 Theme Name:   Child theme name
 Theme URI:
 Description:  Child theme description
 Author:       Your name
 Author URI:
 Template:     parent-theme-folder-name
 Version:      1.0.0
 License:      GNU General Public License v2 or later
 License URI:
 Text Domain:  child-theme-slug

The most important one here is the ‘Template:’ line (line #7, highlighted above) and this should be replaced to match the folder name of the parent theme exactly – this is how WordPress knows which theme that the child theme is related to.

The ‘Theme Name:’ must also be unique to your theme and not used by any other theme you may have installed. All other details should be replaced as applicable.

3. Create a functions.php file

This step is not required for creating a child theme (only the style.css file is actually required) but if you’re going to be making any changes you’re going to need a ‘functions.php’ file.

Create a ‘functions.php’ file within your child theme folder and then add the following code as we’re going to be enqueueing the parent themes stylesheet using the ‘wp_enqueue_scripts‘ action and the ‘wp_enqueue_style()‘ function.

add_action( 'wp_enqueue_scripts', 'child_theme_name_enqueue_styles' );
function child_theme_name_enqueue_styles() {
    $parent_style = 'parent-style'; // This is 'twentynineteen-style' for the Twenty Nineteen theme.
    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 ),

The most important line (line #5 – highlighted above) should match that of the name of the parent themes main stylesheet. This can vary from theme to theme but can usually be easily found by viewing the page source code in your web browser (press ‘Ctrl-U’ in most PC browsers or ‘Option-Command-U’ on Mac) when the parent theme is active.

For example, the Twenty Nineteen stylesheet looks like this in the page source:

<link rel='stylesheet' id='twentynineteen-style-css'  href='' type='text/css' media='all' />

We therefore just need to take the ‘id’ (twentynineteen-style-css), but without the ‘-css‘ part eg. ‘twentynineteen-style’ and use this as the $parent_style.

Activate your new child theme

If you’ve followed the steps above correctly, you should now see your new child theme and be able to activate it in your WordPress admin area under ‘Appearance -> Themes’.


Leave a Reply

Your email address will not be published. Required fields are marked *