How to Create a Child Theme in WordPress
A child theme keeps your customisations safe when the parent theme updates — but in 2026 you don't always need one. Here's when a child theme still matters, and how to build one for classic themes (including Divi) and for block themes.
A child theme is a small theme that inherits everything from another theme — its "parent" — and lets you override just the parts you want to change. The point is safety: if you edit the parent theme's files directly, the next update wipes your changes. A child theme keeps your customisations in a separate folder that updates never touch.
Fair warning: this is one of the more technical topics we cover. Nothing here is hard, but it does involve creating files on your server. If that's not your thing, ask your host or developer — it's a ten-minute job for them.
Do you actually need one in 2026?
That depends on which kind of theme your site runs. This is the big change since most child-theme guides were written.
Block themes (Twenty Twenty-Two and later, plus most newer themes) use the Site Editor under Appearance → Editor. Colours, fonts, spacing, templates, headers, footers — all editable from the dashboard, and all saved to the database rather than the theme's files. A theme update won't overwrite them. For most everyday customisation of a block theme, you don't need a child theme at all.
Classic themes — Divi, Astra, GeneratePress, OceanWP, and the many older themes still in wide use — are a different story. They're built on PHP templates and CSS files, so any custom CSS or PHP you add belongs in a child theme, exactly as before.
You'd still create a child theme, on either kind, if you need to:
- add PHP functions or hooks (e.g. custom shortcodes, tweaks to how a plugin behaves);
- override a specific template file in code;
- ship a bundle of
theme.jsonsettings or CSS you can reuse across sites.
Not sure which kind you have? Look under Appearance. If you see Editor, it's a block theme. If you see Customize (and, on Divi, a Divi menu), it's classic.
Building a classic child theme
1. Create the folder
Inside wp-content/themes, make a new folder named after the parent with a
-child suffix — for example astra-child or divi-child. You can do this
over SFTP or with your host's file manager.
2. Add a style.css with the right header
Create style.css in that folder. WordPress reads the comment block at the top
to recognise the theme. The Template: line is the one that matters — it
must exactly match the parent theme's folder name (case-sensitive).
/*
Theme Name: Astra Child
Description: Child theme of Astra
Author: Your Name
Template: astra
Version: 1.0.0
*/
/* Your custom CSS goes below */
For Divi the folder is Divi, so the line reads Template: Divi.
3. Add a functions.php that loads the parent stylesheet
Create functions.php in the same folder. Its job is to load the parent's
stylesheet so your site doesn't lose its styling. Use wp_enqueue_style —
not the old @import line you'll still see in dated tutorials; that method
is slower and has been discouraged for years.
<?php
add_action( 'wp_enqueue_scripts', 'childtheme_enqueue_styles' );
function childtheme_enqueue_styles() {
// Parent theme's stylesheet first.
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
// Then the child stylesheet, listed as depending on the parent so it loads after.
wp_enqueue_style(
'child-style',
get_stylesheet_uri(),
array( 'parent-style' ),
wp_get_theme()->get( 'Version' )
);
}
get_template_directory_uri() points at the parent folder;
get_stylesheet_uri() points at the child. Listing parent-style as a
dependency guarantees your overrides load last and win.
4. Activate it
Go to Appearance → Themes, find your child theme, and click Activate.
The site should look identical — it's inheriting everything from the parent.
From now on, CSS in the child's style.css and code in its functions.php
survive every parent update.
A note on Divi
Many small-business sites — including a good share of the ones we host — run
Divi. Divi is a classic theme, so a Divi child theme is still the standard
way to add custom PHP or CSS there. The steps above apply unchanged, with
Template: Divi.
For a handful of CSS lines, Divi's own Theme Options → Custom CSS box also survives updates and is simpler. Reach for the child theme once you have PHP, a template override, or enough CSS that you want it in a real file under version control. Either way, never edit Divi's own files — it updates often.
Child themes for block themes
If you do need a child of a block theme, the structure is different: it's
mostly theme.json and template files rather than PHP.
style.csswith the same header (andTemplate:line) — this is still what identifies it as a child theme.theme.jsonfor settings and styles you want to override — colours, fonts, layout widths. Anything you leave out is inherited from the parent.- Optional
templates/andparts/folders holding only the templates you're overriding. functions.phpis optional. Block themes generally load the child'sstyle.cssautomatically; if yours doesn't, the enqueue snippet above works here too.
You don't have to build this by hand. The Create Block Theme plugin, maintained by the WordPress core team, can generate a child of your active theme in a couple of clicks — and it can export the changes you've already made in the Site Editor into that child. That's the route we'd suggest for most people.
A safe place to experiment
Whichever route you take, do it on a staging copy first and take a backup
before activating. A stray bracket in functions.php can take a whole site
down, and it's far less stressful to break a copy than the live site. If your
host offers one-click staging and automatic backups, this is exactly what
they're for.
Let Site Schema handle this for you.
Managed WordPress hosting with the hard parts done for you.
Need a hand? Our support team can set this up for you