How to create a child theme on WordPress (and why you should)

A child theme allows you to make customisations to different aspects of your site’s appearance while preserving your theme’s style and functionality.

A parent theme includes all of the required WordPress template files and assets for the theme to work. A child theme works like any other theme, except it inherits the style and functions of the parent theme. Customisations are kept separate meaning that they won’t be lost when upgrading the parent theme.

There are quite a few things you can do with child themes – like customising your theme, overriding parent settings, creating custom page templates and so on. This post will show you how to create a child theme on WordPress.

How to create a WordPress child theme

How to create a WordPress child theme

While you can use a plugin for this, I recommend doing it manually. Here are the steps…

1. Make sure your parent theme is present in Appearance > Themes. For this example, let’s use the Twenty Nineteen theme.

2. Login to your site via FTP and locate your theme folder (wp-content > themes). Don’t know how to access your site via FTP? Check out the tutorial here.

3. Create a new folder within the theme folder, name it something memorable (like twentynineteen-child)

4. Create a file within the folder titled style.css

5. Open the style.css file in a text editor and paste the below snippet, changing the details as needed. The value for Template should be the name of the parent theme.

/*
Theme Name: Twenty Nineteen Child
Description: A child theme of Twenty Nineteen
Author: Your Name
Version: 1.0
Template: twentynineteen
*/

6. Create another new file within the folder titled functions.php and add the following

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

7. Save both files and upload them to the child theme via FTP.

8. Once uploaded, go to your WordPress Dashboard. Click Appearance > Themes and activate your child theme.

9. Now you can add your customisations to the child theme. You can override any of the files from your parent theme. For example if you want to override CSS, add the customisations to the style.css file in your child theme.

10. Now when you update your parent theme, in this case Twenty Nineteen, the updates will take effect on your child theme, Twenty Nineteen Child, but your overrides will still be in place.

Buy me a coffeeBuy me a coffee