
If you have ever opened a theme’s functions.php or a template file and typed your changes directly into it, you have set a trap for your future self. The next time that theme updates, whether you click the button or a host applies it automatically, every one of your edits disappears. A child theme fixes this permanently, and it takes about ten minutes to set up.
Why Direct Theme Edits Always End Badly
Themes get updates for real reasons: security patches, compatibility fixes for new WordPress releases, and bug fixes. When you edit the parent theme’s files directly, you are editing files that WordPress considers disposable. An update simply overwrites them with the new version. Your custom CSS, your tweaked header markup, your extra PHP function: all gone, with no warning beyond a changelog you probably didn’t read.
The workaround some people reach for is disabling theme updates entirely. That trades one problem for a worse one. Now you are running an outdated theme indefinitely, missing security fixes, and slowly drifting incompatible with newer WordPress and PHP versions. Neither option is good. A child theme is the actual fix.
What a Child Theme Actually Is
A child theme is a small, separate theme that inherits everything from a parent theme (its templates, styles, and functions) but can override any piece of it. WordPress loads the parent theme’s files as a base, then layers your child theme’s files on top wherever they exist. Update the parent theme all you want; your child theme’s folder is untouched because it lives completely separate from the parent’s files.
At its simplest, a child theme is just two files: a style.css with a special header comment, and a functions.php. From there you can add as much or as little as you need: full template overrides, custom CSS, additional PHP functions, or all three.
The 10-Minute Setup
Start by creating a new folder inside wp-content/themes/. Name it something clear, like twentytwentyfour-child if your parent theme is Twenty Twenty-Four.
Inside that folder, create style.css with this header:
/*
Theme Name: Twenty Twenty-Four Child
Template: twentytwentyfour
Version: 1.0.0
*/
The Template line is the one that matters most. It must exactly match the folder name of the parent theme, not its display name. Get that wrong and WordPress won’t recognize the relationship, and your site will look broken because the parent’s stylesheet never loads.
Now go to Appearance > Themes in wp-admin. Your child theme will appear as a new theme. Activate it. Your site should look identical to before, because right now the child theme is just borrowing the parent’s stylesheet through the theme header. Any CSS you add below the header comment in style.css will apply on top of the parent’s styles.
Enqueuing Parent and Child Styles Correctly
Modern WordPress themes need a functions.php in the child theme to properly load both parent and child stylesheets, because block themes and many classic themes don’t automatically pull in the child’s style.css file content on their own in every case. Add this to your child theme’s functions.php:
<?php
function serverborn_enqueue_child_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', 'serverborn_enqueue_child_styles' );
This loads the parent’s styles first, then the child’s on top, so your overrides win without duplicating the parent’s entire stylesheet. If the parent theme already enqueues its own stylesheet by a handle you can reference, you can list that handle as the dependency instead of re-enqueuing it, which avoids loading it twice.
Adding Your Own Functions Safely
This same functions.php file is where you add custom PHP: a shortcode, a filter that adjusts an image size, a small tweak to how excerpts are generated. Unlike the parent theme’s functions.php, this one is never touched by parent theme updates. Just be careful naming your functions. Prefix them with something unique to your project (as in the example above) so they never collide with a function name the parent theme or a plugin might also define.
Overriding Template Files
To override a specific template, copy the file from the parent theme into the same relative path inside your child theme folder, then edit the copy. For example, to override parent-theme/template-parts/content.php, create child-theme/template-parts/content.php with your changes. WordPress will use your child theme’s version instead of the parent’s automatically. This works for most template files, though block themes handle some templates through the site editor rather than plain PHP files, so check whether your parent theme is block-based or classic before assuming a straight file copy will work everywhere.
Creating a Child Theme with wp-cli
If you manage sites from the command line, wp-cli can scaffold the basic child theme files for you in one step:
wp scaffold child-theme twentytwentyfour-child --parent_theme=twentytwentyfour --theme_name="Twenty Twenty-Four Child"This generates the style.css and functions.php with the enqueue code already written, saving you the manual setup above. It’s a fast way to standardize child theme creation across multiple sites.
Common Mistakes to Avoid
- Getting the
Templatevalue wrong instyle.css. It must match the parent theme’s folder name exactly, case included. - Editing the parent theme’s
style.cssinstead of the child’s, out of habit. Double-check which file is open before you save. - Assuming a child theme protects plugin files too. It only protects theme files. Plugin customizations need their own approach, usually a small custom plugin.
- Forgetting that major structural changes in a parent theme update (renamed template parts, restructured block templates) can still require you to update your child theme’s overrides, even though your basic setup survives. A child theme prevents accidental data loss, not every possible compatibility issue.
Takeaway
A child theme costs you ten minutes now and saves you hours of redone work later. It keeps your customizations separate from the parent theme’s code, so updates stay safe to apply and your site stays current on security fixes instead of frozen in place out of fear. If you are still editing a parent theme directly, this is the single highest-value habit to change today.