How to Create a WordPress Child Theme the Right Way

There’s a mistake I see on client sites pretty regularly. Someone has gone into the parent theme files, made changes — tweaked some CSS, added a function, modified a template — and it all looks great until the theme updates. Then it’s gone. Every single edit, gone.

Creating a WordPress child theme is the fix. It’s not complicated, but there are a few things worth understanding before you set one up — especially since WordPress now has two distinct theme types that each require a different approach. This guide covers both.

What a Child Theme Actually Does

A child theme inherits everything from its parent — the templates, the styles, the functionality. You make your changes inside the child theme’s files instead of the parent’s. When the parent updates, your changes stay untouched because they’re in a completely separate location. That’s the whole point. WordPress’s official documentation on child themes describes the inheritance model in detail if you want to go deeper on how the file hierarchy works.

Beyond protecting updates, a child theme keeps your project organised. What came with the theme and what you built are clearly separated. That matters when you’re debugging something months later, or when someone else picks up the project after you.

Classic Themes and Block Themes Are Not the Same

Before doing anything, you need to know which type of parent theme you’re working with. The setup is different for each.

Classic themes — Astra, GeneratePress, Hello Elementor, most third-party themes — are PHP-based. You work with style.css and functions.php.

Block themes — Twenty Twenty-Four and others built for Full Site Editing — use theme.json for design settings and HTML files for templates. No functions.php is needed for basic customisation.

To check which you’re dealing with: look inside the parent theme’s folder in wp-content/themes/. If there’s a templates/ folder and a theme.json file, it’s a block theme. Otherwise, classic.

How to Create a Child Theme for a Classic PHP Theme

You need two files. Create a new folder inside wp-content/themes/ — name it after the parent with “-child” added, like hello-elementor-child. Then:

First, create style.css:

/*
Theme Name:   Hello Elementor Child
Description:  Child theme for Hello Elementor
Author:       Your Name
Template:     hello-elementor
Version:      1.0.0
*/

⚠ The Template value must match the parent theme’s folder name exactly. One wrong character and WordPress won’t recognise the relationship between the two themes.

Then create functions.php in the same folder:

<?php
function my_child_enqueue_styles() {
    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' )
    );
}
add_action( 'wp_enqueue_scripts', 'my_child_enqueue_scripts' );

The array( ‘parent-style’ ) tells WordPress to load the parent stylesheet first, then the child. Without that dependency, the loading order isn’t guaranteed and you’ll end up with styles overriding each other in the wrong direction.

One thing to double-check: the handle in the first wp_enqueue_style call should match what the parent theme registered. Most themes use something like ‘parent-theme-style’. If you’re not sure, open the parent’s functions.php and find its wp_enqueue_style call — the first argument is the handle.

Once the files are in place, go to Appearance > Themes, activate the child theme, and make sure the site still looks correct.

If you’d rather skip the manual setup, Child Theme Configurator is a solid plugin that handles the file generation through a dashboard UI. It’s well-maintained and works well for classic themes.

How to Create a Child Theme for a Block Theme

The structure here is simpler. You still need a style.css with the same header format, but instead of functions.php, your customisation goes into theme.json. WordPress merges your child’s theme.json with the parent’s automatically — you only need to include the values you want to change, not copy the entire file.

/* style.css */
/*
Theme Name:   My Block Child
Template:     twentytwentyfour
Version:      1.0.0
*/

// theme.json — only override what you need
{
  "$schema": "https://schemas.wp.org/trunk/theme.json",
  "version": 3,
  "settings": {
    "color": {
      "palette": [
        { "slug": "primary", "color": "#1D4ED8", "name": "Primary" }
      ]
    }
  }
}

To override a specific template, create a templates/ folder inside your child theme and place the template file there. WordPress will use yours instead of the parent’s for that context. The theme.json reference in the WordPress developer docs is the best place to look up what can be customised through it.

When a Child Theme Isn’t the Answer

If your site is entirely built in a page builder — Elementor, Bricks, Beaver Builder — and you’re not touching any theme files directly, a child theme doesn’t protect much. Page builder layouts live in the database, not in theme files. A child theme protects theme file edits, not database content.

If you’re building a theme from scratch, you already own all the files — no child theme needed.

The short version: use a child theme when you’re editing theme files and need those edits to survive updates. If everything you’ve done is inside a page builder or the WordPress customizer, you probably don’t need one.

A Note on Theme Sources

A child theme only works as intended if the parent theme is legitimate. Nulled or cracked premium themes are consistently distributed with malware baked in — no child theme structure protects you from that. If you’re not sure why this is a serious problem, this post explains it fully. The short answer: recovery always costs more than the original license would have.

Keeping your parent theme updated is also tied to your overall security posture. The WordPress security guide covers what actually matters on that front if you want to go through it.

Fixing Common Problems

Parent styles not loading: check that the Template value in style.css matches the parent folder name exactly, and that the stylesheet handle in your functions.php matches what the parent registered.

PHP errors or broken functionality after activating: check functions.php for syntax errors. Enable WP_DEBUG in wp-config.php while developing — it surfaces issues that otherwise fail silently. Also check whether the parent theme already declared a function with the same name you’re adding.

Child theme not appearing in Appearance > Themes: WordPress requires both a valid style.css header and a folder that sits directly inside wp-content/themes/. If the theme isn’t showing up, check both.

Worth Doing Right

Child themes are one of those things in WordPress that seem like extra work until the day a theme update wipes something important. At that point the ten minutes it would have taken to set one up properly looks very different.

Classic theme or block theme, the concept is the same. Keep your changes separate from the parent, know which file handles what, and you’ll save yourself a lot of avoidable headaches down the line.


Leave a Comment

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

Table of Contents

Scroll to Top
Let's Chat!

Tell me about your project and get a free quote.