How to Create a WordPress Child Theme in 2024 (Simplest Step-by-Step Guide)

Martin T. | September 4, 2024 

How to Create a WordPress Child Theme

Table of Contents

“What is a WordPress child theme? Do you still need to create a child theme in 2024? What are the advantages, and how do you create one?

A child theme is a way to modify, customize, or enhance the functionality and appearance of your current WordPress theme without altering the parent theme’s files. By using a child theme, you can ensure that your customizations are preserved when the parent theme is updated. This approach prevents the loss of changes that would otherwise occur during theme updates.

In this quick guide, we will explain what a child theme is, why you may need one, and how to create a child theme all by yourself easily.

What is a WordPress Child Theme?

A WordPress child theme is an extension of a parent WordPress theme. It inherits the functionality and styling of the parent theme and allows you to make modifications without altering the parent theme’s files. This means any customizations you apply to the child theme will not be overwritten when the parent theme is updated.

You can think of a child theme as a “replica” of a parent theme that you can tweak and customize. Changes made in the child theme do not affect the parent theme directly; instead, they override or add to the existing features and styles. This setup ensures that the parent theme remains intact, allowing for safe and easy updates.

Why Use a Child Theme?

Most likely, you are using a theme developed by someone else. Developers frequently release updates to their themes to address security vulnerabilities, fix bugs, and ensure compatibility with the latest version of WordPress and other plugins. Without these updates, your website could become vulnerable to malware attacks or experience functionality issues due to code incompatibility.

When you update your theme to the latest version, WordPress replaces the old version with the new one. If you have made customizations directly to the parent theme’s code, those changes will be lost in the update.

Using a child theme ensures that your customizations are preserved even when the parent theme is updated. Any changes you make in the child theme will automatically apply to the updated parent theme. Unlike parent themes, child themes do not get updated; you have full control to make any changes as needed.

Creating a child theme allows you to make adjustments to your site without risking the loss of customizations when the parent theme is updated or exposing your site to vulnerabilities by using outdated code.

Child themes are beneficial for all types of WordPress websites, including blogs, e-commerce sites, LMS websites (online course websites), portfolio sites, non-profit sites, writing and publishing websites, and more.

How Does a WordPress Child Theme Work?

A child theme inherits all the features, functions, and styles of a parent theme and is set up to mimic its structure, including file names, code connections, and folder structures.

A child theme allows you to override or extend the parent theme’s features and functionalities without editing the parent theme directly. This means you can customize the parent theme without the risk of losing your changes when the parent theme is updated.

You don’t need to copy all the files from the parent theme into the child theme. Instead, you only replicate the files and folders you wish to modify. This approach makes child themes easier to manage and lightweight.

Changes made in a child theme override or extend the code in the parent theme, including modifications in CSS, PHP, JavaScript, etc. Having a basic understanding of these coding languages and WordPress hooks will facilitate the creation and customization of your child theme.

For a child theme to work, the parent theme must be installed on your WordPress website. A child theme cannot function independently and relies on the parent theme’s functionalities. After installing both themes, you activate the child theme instead of the parent theme. Activating the parent theme will negate the effects of the customizations made in the child theme.

When you activate the child theme, WordPress first checks for files in the child theme’s folder. If a file is not found in the child theme, WordPress will use the corresponding file from the parent theme’s folder.

It’s important to note that child themes are not universal. They are tied to a specific parent theme. For example, a child theme for the OceanWP theme will not work with the Astra theme. Therefore, if you switch parent themes, you will need to create a new child theme for the new parent theme.

Add precautions before you begin the section: 

For example, – work on a local or staging or dev site if you are learning. 

Backup your website

How to Create a WordPress Child Theme Manually (Step by Step)

Creating a child theme manually is straightforward. You can create your child theme locally or directly on your WordPress site in the wp-content/themes folder. You can work directly on the site using a FTP client or your cPanel’s File Manager. You can also use a WordPress File Manager plugin.

If you choose to create a child theme directly on your site, and you are not a WordPress developer, we recommend using a staging or dev site before deploying it to your live site to minimize risks.

With that in mind, follow these steps to create a child theme for your WordPress site:

Step 1: Create a Child Theme Folder

The first thing you need to do is create a folder for your child theme. 

It’s best to create this folder in the. 

Name the folder based on the parent theme you want to create the child theme for, appending -child to it. Ensure there are no spaces in your child theme directory name. For example, if your parent theme is named “Astra,” you would name your folder astra-child.

WordPress Child Theme Astra

Step 2: Create a stylesheet for the child theme

The second thing you need to do is create a style.css file in the child theme folder.

Open your code editor, and copy the style.css file header comments from the code below (or from the original theme) into the code editor. 

The two most important elements that must be present in the file header comments are the Theme Name and Template directory (as highlighted in the code below).

/*
Theme Name: Astra Child Theme
Theme URI: https://wpastra.com/
Author: Brainstorm Force
Author URI: https://wpastra.com/about/?utm_source=theme_preview&utm_medium=author_link&utm_campaign=astra_theme
Template: astra
Description: Child Theme of Twenty Twenty-Two
Version: 1.1
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: astra-child
Domain Path: /languages
Tags: custom-menu, custom-logo, entertainment, one-column, two-columns, left-sidebar, e-commerce, right-sidebar, custom-colors, editor-style, featured-images, full-width-template, microformats, post-formats, rtl-language-support, theme-options, threaded-comments, translation-ready, blog
AMP: true

Astra WordPress Theme, Copyright 2020 WPAstra.
Astra is distributed under the terms of the GNU GPL.
*/
Astra Child Theme File

Note: The Template directory is the parent theme folder name as located in the wp-content/theme folder. If it is not the same, the WordPress core will not be able to link the child theme to the parent theme.

When you are done, save the file as a style.css file.

Technically, you can add your custom CSS rules to the style.css file at this step or later in the future. 

Step 3: Enqueue the Parent and Child Themes’ Stylesheets

Next, you need to create a functions.php file in the child theme’s folder to enqueue the parent and child theme’s stylesheet. 

When you create the functions.php file, copy the codes below into it and save the changes. Doing this lets you make overriding changes to the CSS of the parent theme.

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

You can insert new functions here but do not copy existing functions from the parent theme here to avoid code duplication conflicts. When you are done, save the functions.php file in the child theme next to the style.css file.

Astra Child Theme Styles

Step 4: Customize Templates Parts, Patterns & Custom Files

If you have intentions to customize or override certain aspects of the parent theme, such as template, part, or pattern, you can download the parent theme, and copy the target files and folders to your child’s theme ensuring to follow the corresponding path.

You can also add entirely new templates, parts, and patterns to your child’s theme, even if they never existed in the parent theme. With hooks and some custom functionality, you can also include or use custom files in your child’s theme by referencing them with the functions.php file. 

Note: You can skip step 4 entirely. The minimum requirement for a child theme is the style.css and function.php file (even with just the field header comment and the enqueue script.

Step 5: Install and activate your child theme

Your child theme is now ready! Compress it to a zip format and upload it to your WordPress website.

Compress Child Theme File

Go to Appearance > Themes > Add New Theme > Upload Theme.  Use the uploader to select and upload your child theme.

Uploading Child Theme

If you have not already installed the parent theme, you may be prompted to install and activate the parent theme from the WordPress repo. If it’s already installed, you will also be notified.

Installing Child Theme

After uploading the parent and child theme. you may want to preview the child theme first to be certain that it won’t cause any fatal errors peradventure there’s a mistake in the child theme creation process. If there are no issues, proceed to activate the child theme. 

WordPress Dashboard Appearance

Note: If you wish to add a cover image to your child theme, simply rename your choice cover image to screenshot.jpg and add it to the child theme folder before zipping the folder.

Alternative No-Code Ways to Create a Child Theme in WordPress

If you are not tech-savvy and prefer an easier no-code approach to creating a child theme for your website, then let’s explore how you can create a child theme in WordPress without having to code one up by yourself.

Option 1: Use a Pre-Made WordPress Child Theme by your Theme Developer

Some WordPress developers understand the need for a child theme in WordPress and go out of their way to create a child theme for their plugin. For example, WordPress Themes like OceanWP and Genesis offer downloadable child themes for free.

You can look up your theme developer’s official website or Google for available child themes for your current theme or the theme you intend to use. If available, simply download and upload the child theme on your WordPress site.

Some theme developer, like Astra Theme for example offers their own WordPress child theme generator tool that will automatically create a child theme with the necessary files for you.

The use of a pre-made WordPress child theme from your developer might be a safer option for you, but if there are no child themes available for you to download, then you can proceed with the next option.

Option 2: Use a WordPress Child Theme Generator Plugin

There are several child theme creator WordPress plugins that you can use to create a child theme for your WordPress website with just a few clicks. Here are some of the most popular free child theme plugins.

In this tutorial, we will make use of the WP Child Theme Generator. You can install it directly on your WordPress website from the WordPress plugin repo.

From your WordPress dashboard, go to Plugins > Add New Plugin.

Search for WP Child Theme Generator from the right search field. Click Install and then Activate.

Install WP Child Theme Generator

Once installed and activated, you can access the plugin under Appearance. Go to Appearance > Child Theme Gen.

Select the theme you want to generate a child theme for and fill the fields below as you wish, or leave the default options.

Select Your Theme-WP Child Theme Generator
Create Child Theme-WP Child Theme Generator

When you are done, click the Create Child Theme button. The child theme will be created instantly. You can return to your Themes section to check out and activate your newly created child theme.

Child Theme Generated

Wrapping Things Up

And that’s it! I hope you now know what a WordPress child theme is, and this guide was able to assist you in creating a child theme for WordPress if you happen to need one for your WordPress-hosted website or blog.

Author

Martin T.
Martins T. is a passionate and experienced WordPress and hosting content writer. He specializes in crafting SEO-friendly blog posts and creating persuasive website copy, to elevate your online presence. He has a thing for e-commerce and humor.
cPanel + LiteSpeed Enterprise + NVMe
Fast WordPress Hosting 
Starts at $1
What to read next?