WordPress

The Update That Erased Your Edits: A WordPress Child Theme Guide

8 min read

Sooner or later, every WordPress owner wants to change something the theme won’t let them adjust from a settings panel. A color the customizer doesn’t expose, a bit of spacing, an extra function in the footer. So you open the theme’s style.css, make the edit, and it works. Problem solved — until the theme author ships an update a month later and your change vanishes without a trace.

We took over a site last year where the previous developer had spent months tweaking the active theme’s files directly. Then a routine “you have 1 update available” click overwrote the whole theme folder, and every one of those edits was gone in a single afternoon. There was no backup of the customizations because they only ever lived inside files that WordPress happily replaced.

A child theme is the fix, and it’s been the officially recommended way to customize WordPress for well over a decade. It lets you change almost anything about a theme while keeping your edits completely separate from the theme you’re modifying, so an update can never touch them.


What a Child Theme Actually Is

A child theme is a theme that inherits the look and behavior of another theme, called the parent. WordPress loads the parent normally, then loads your child theme on top of it and lets the child’s files take priority. You end up running the parent theme’s code, plus your own small set of overrides.

The important part is that your overrides live in a separate folder. When the parent theme’s author releases version 2.4 and you update, WordPress replaces the parent folder and leaves your child folder untouched. Your customizations survive because they were never inside the thing that got replaced.

WHY IT MATTERS

Editing a parent theme’s files directly is the single most common way people lose work in WordPress. The next theme update overwrites the entire folder, and there’s no “undo.” A child theme moves your edits somewhere updates can’t reach, which is why it’s the approach WordPress’s own theme handbook recommends for any customization you want to keep.

When You Need One (and When You Don’t)

Child themes are worth the small setup effort whenever you’re changing theme files — CSS, template markup, or PHP functions — on a theme you didn’t build yourself and expect to keep updated. That covers most sites running a third-party theme from the WordPress directory or a marketplace.

Cases where a child theme is the right tool

  • You want to add or override CSS beyond what the customizer or “Additional CSS” box allows
  • You need to edit a template file — say, changing the markup of single.php or a WooCommerce template
  • You’re adding custom functions, filters, or hooks in functions.php that should stay tied to this theme
  • You’re handing the site to a client and want your changes to survive their update habits

Cases where you probably don’t need one

Not every change requires a child theme, and it’s worth knowing the exceptions so you don’t over-engineer. If your only edit is a few lines of CSS, WordPress has shipped an Additional CSS box in the Customizer since version 4.7, and that CSS is stored in the database, not the theme, so updates leave it alone. Site-wide options that the theme exposes in its own settings are safe too.

Block themes complicate the picture in a useful way. If you’re running a modern block theme and you make your changes through the Site Editor — templates, styles, template parts — those edits are saved to the database as well, not to theme files, so a parent update won’t erase them either. A child theme is still the cleaner choice when you want file-based, version-controlled changes or custom PHP, but casual visual tweaks in the Site Editor are already update-safe.

Building a Child Theme by Hand

A working child theme can be as small as two files. It really is that minimal, and doing it by hand once is the best way to understand what the “generator” plugins are actually creating for you.

Step 1: Create the folder

Inside wp-content/themes/, make a new directory. Name it after the parent with a -child suffix by convention — if the parent folder is twentytwentyfour, call yours twentytwentyfour-child. The name is just a convention; what matters is the file inside.

Step 2: Add style.css with the right header

Create a style.css in that folder. WordPress reads a comment block at the top to identify the theme, and two lines in it are non-negotiable: Theme Name and Template. The Template value has to match the parent theme’s folder name exactly, and it’s case-sensitive — this is the line that tells WordPress which parent to inherit from.

/*
 Theme Name:  Twenty Twenty-Four Child
 Template:    twentytwentyfour
 Version:     1.0.0
*/

Get the Template value wrong and WordPress will refuse to activate the child, usually with a “broken theme” notice — a misspelled or wrong-case parent folder name is the number-one reason a hand-built child theme won’t turn on.

Step 3: Add functions.php to load the parent’s styles

Older tutorials told you to pull in the parent’s stylesheet with an @import line inside style.css. WordPress’s own documentation moved away from that years ago because it’s slower — the browser has to download the child CSS before it even discovers the import. The current best practice is a tiny functions.php that enqueues the parent stylesheet properly:

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

One detail trips people up here: get_template_directory_uri() points at the parent theme, while get_stylesheet_directory_uri() points at your child. Mix those up and you’ll load the wrong stylesheet. With classic themes you generally want the parent’s style.css loaded; with many modern themes the parent handles its own enqueuing and you may not need this step at all, so test before assuming.

KEY POINT: functions.php is the exception

For every template file, a child theme’s version replaces the parent’s. Put a page.php in your child theme and WordPress uses it instead of the parent’s page.php. But functions.php works differently: the child’s functions.php loads in addition to the parent’s, and it loads first. That’s what lets you add new functions without recreating the parent’s entire file.

How Overrides Actually Resolve

Once the child theme is active, WordPress follows a simple rule when it needs a template: look in the child theme first, and only fall back to the parent if the child doesn’t have that file. So to change how single posts render, you copy single.php from the parent into your child, edit your copy, and WordPress quietly stops using the parent’s version.

This is why you never copy the whole parent theme into your child. You copy only the specific files you intend to change. Everything you don’t override keeps coming from the parent, which means the parent’s next update still improves all those untouched files.

The order of precedence, in plain terms

  • Template files — child wins if present, otherwise the parent’s file is used
  • functions.php — both run; the child’s loads immediately before the parent’s
  • style.css — the child’s stylesheet is what WordPress registers as the theme stylesheet; you decide whether to also load the parent’s
  • For block themes, a child’s theme.json is merged over the parent’s, and block templates in the child override same-named parent templates

The Faster Route: Generate It

If hand-editing PHP isn’t your idea of a good afternoon, plugins like the long-running “Child Theme Configurator” or “Create Block Theme” (the latter maintained by WordPress.org itself for block themes) will scaffold a correct child theme in a couple of clicks, wire up the stylesheet enqueue, and even copy over the template files you pick. They’re genuinely useful, especially for block themes where the file layout is less familiar.

Use them if you like, but understand what they produce. A generated child theme is the same folder, the same style.css header, and the same functions.php you’d write by hand. Knowing that makes it far easier to debug the day something doesn’t inherit the way you expected.

Testing Before You Rely On It

Activate the child theme and walk the whole site before you call it done, because a child theme that’s active but subtly misconfigured can look fine on the homepage and break on a single post or a WooCommerce page. Check that styles load, that your overridden templates render, and that nothing in the browser console is 404-ing for a missing stylesheet.

Do this on a staging copy first if the site is live. A child theme is low-risk as changes go, but “low-risk” and “no-risk” aren’t the same thing, and the whole point of the exercise is to stop surprising yourself with production changes. If you don’t have a staging environment yet, that’s worth setting up before your next round of customizations.


Frequently Asked Questions

A child theme is a separate theme that inherits the design and functionality of another theme, called the parent. WordPress loads the parent, then applies your child theme’s files on top, letting the child override specific pieces. Because your changes live in the child theme’s own folder, updating the parent theme never overwrites them.

Not necessarily. For a small amount of CSS, the Customizer’s “Additional CSS” box (available since WordPress 4.7) stores your styles in the database rather than in theme files, so theme updates leave them intact. A child theme becomes the better option once you need to edit template files, add custom PHP functions, or manage a larger, version-controlled set of changes.

At a minimum you need a folder and a style.css file whose header comment includes a Theme Name and a Template line naming the parent theme’s folder. In practice you almost always add a functions.php as well, to enqueue the parent’s stylesheet correctly and to hold any custom functions. That’s it — two files can make a fully working child theme.

No, and this is the important exception. Unlike template files, which the child overrides, both functions.php files load — the child’s runs first, then the parent’s. That means you only add the new or modified functions to your child’s functions.php; you never need to copy the parent’s entire file, and doing so would cause duplicate-function errors.

Yes. A block theme can be a parent, and a child theme can override its templates and template parts and provide its own theme.json, which is merged over the parent’s. Note that customizations made directly in the Site Editor are saved to the database rather than to theme files, so those also survive parent updates. Child themes remain useful for file-based, version-controlled changes and custom PHP.

The most common cause is a wrong Template value in style.css. It must exactly match the parent theme’s folder name, including capitalization, and the parent theme must be installed. Double-check the folder name under wp-content/themes, confirm the Template line matches it character for character, and make sure your style.css header comment is well-formed.

Customizing a client site and want the changes to outlast every future update? A child theme is thirty minutes of setup that saves you from ever losing an edit to a theme upgrade again.

Built by amplifi.studio — see also One Bad Update From a White Screen: setting up a WordPress staging site.