Child Themes: Customizing Without Losing Updates
· 2 min read
You now know themes well enough to install one and customize it through the Customizer or the Site Editor.
You now know themes well enough to install one and customize it through the Customizer or the Site Editor. But there's a trap waiting for anyone who starts editing a theme's actual files directly to make deeper changes: the moment that theme gets updated, your edits are gone. Child themes exist specifically to solve that problem, and understanding them properly will save you from losing real work later.
Why Theme Updates Erase Edits
Here's the root issue. Every theme you install from the WordPress directory gets updated periodically, for security fixes, new features, or compatibility with newer WordPress versions. WordPress applies those updates by replacing the theme's files with the new version's files. If you'd opened up the parent theme's own style.css or header.php and typed your changes straight into them, an update overwrites those exact files, and your changes vanish with no warning, no backup, nothing to undo. This has caught out more beginners than almost any other WordPress habit, usually right after they've put hours into getting a theme looking exactly right. A child theme sidesteps this entirely by keeping your customizations in a completely separate set of files that live alongside the parent theme rather than inside it. WordPress loads the parent theme's functionality as the base, then layers your child theme's files on top, overriding specific pieces. When the parent theme updates, it only touches the parent theme's own files — your child theme folder is never touched, so nothing you've customized gets erased.
Creating A Child Theme
Creating one is simpler than it sounds. You need a new folder inside wp-content/themes/ (separate from the parent theme's folder), containing at minimum a style.css file with a specific header comment block that tells WordPress which theme it's a child of.
/*
Theme Name: My Child Theme
Template: twentytwentyfour
*/
That Template line is the part that actually matters functionally — it must exactly match the folder name of the parent theme (not its display name), and it's what tells WordPress "load this as a child of that theme." Get that folder name wrong, even by a character, and WordPress won't recognize the relationship at all. On its own, though, that style.css header doesn't pull in the parent theme's actual CSS — it only establishes the parent/child relationship and holds your own custom styles. You also need a functions.php file in the child theme folder that loads the parent theme's stylesheet, then your own child stylesheet on top of it, so both sets of styles apply.
<?php
function my_child_theme_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_theme_enqueue_styles');
Understanding The Code
Walking through this: get_template_directory_uri() points to the parent theme's folder, while get_stylesheet_directory_uri() points to the child theme's own folder — those two functions are easy to mix up because the names sound similar, but the distinction is exactly the point of a child theme. The array('parent-style') part on the child stylesheet line tells WordPress to load the parent's CSS first, then the child's CSS after it, so anything you write in the child's style.css can override a parent style simply by targeting the same CSS selector — a later rule for the same selector wins, which is ordinary CSS behavior, not anything WordPress-specific. Once that functions.php and style.css exist, the new child theme shows up in Appearance > Themes just like any other installed theme, ready to activate. From that point on, any file you place inside the child theme's folder with the same name and path as a file in the parent theme — header.php, footer.php, single.php, and so on — completely replaces that parent file when WordPress builds the page, while every file you don't override still comes from the parent theme untouched. This is the real power of the system: you only need to recreate the one or two files you actually want to change, not copy the entire parent theme.
A Mistake To Avoid
A mistake worth naming directly: don't edit the parent theme to "test something quickly" and plan to move it to the child theme later. That's exactly the habit that causes lost work, because it's easy to forget, and an automatic update can land before you move it. Get comfortable making even small, one-line changes in the child theme from the very start, so there's never a window where your customization only exists in a file that updates will wipe out. It's also worth knowing child themes aren't only for CSS tweaks. Once you're comfortable with PHP, you can add your own functions to a child theme's functions.php — unlike template files, functions.php doesn't replace the parent's version, it runs in addition to it, so you can add new features without touching a single parent theme file. That makes functions.php one of the safest places in all of WordPress theme development to experiment, since mistakes there affect only your added code, not the parent theme's own logic.
Quick Exercise
A quick exercise: on a local or test WordPress install (never on a live site you can't afford to break), create a new folder in wp-content/themes/, add a style.css with the Theme Name and Template header shown above, matching whatever theme you currently have active as the parent, and add the functions.php that enqueues both stylesheets. Activate it under Appearance > Themes and confirm the site still looks identical — that confirms the parent theme's styles are loading correctly through the child.
KEEP READING