How to set up a WordPress child theme, and why
What a child theme is, when you need one, and how to create one for a classic or block theme without breaking updates or styles.
At a glance
A guide to WordPress child themes: what they are, when you need one and when Additional CSS or a small plugin is enough. It gives the files for a classic theme and for a block theme, explains how to override templates and parent functions safely, lists what to check after a parent update, and includes a troubleshooting table.
Updated November 29, 2026 · For WordPress site owners and developers
- For site owners and developers customizing a theme
- Need one when you edit template files or add theme PHP
- Not needed for CSS-only changes or theme options
- Classic theme style.css with Template, plus functions.php
- Block theme style.css with Template, optional theme.json
- After parent updates compare any template files you copied
On this page
- Why use a child theme at all?
- How do I create a child theme?
- How do I override a template file?
- A worked example: changing one template
- How do I change a parent function safely?
- What do I check after a parent update?
- Troubleshooting
- Should the code live in the child theme at all?
- What mistakes should I avoid?
- FAQ
A child theme is a small theme that inherits everything from a parent theme, so you can change templates, styles and functions without editing the parent. Create one before you modify any theme file, because a parent theme update overwrites your edits.
Why use a child theme at all?
When the theme author releases an update, WordPress replaces the parent theme's folder. Anything you edited there is gone, and so is the security fix you wanted. A child theme keeps your changes in a separate folder, so you can update the parent safely.
| What you want | Use |
|---|---|
| Only CSS changes | Additional CSS (Customizer) or Site Editor styles, stored in the database |
| Change settings or colours | The theme's own options, no child theme |
| Edit template files, add theme PHP, register blocks or patterns | A child theme |
| Add functionality unrelated to appearance, such as a custom post type or shortcode | A small plugin, so it works if you change theme |
How do I create a child theme?
Take a backup first. Then connect by SFTP or your host's file manager. In wp-content/themes/, create a folder, for example mytheme-child. Use the parent's folder name plus -child so it is easy to recognise.
Inside the folder, create style.css:
/*
Theme Name: MyTheme Child
Template: mytheme
Version: 1.0.0
*/Template must be the exact folder name of the parent, not its display name. Theme Name can be anything unique. Then create functions.php in the same folder to load the parent's styles:
<?php
add_action( 'wp_enqueue_scripts', function () {
$parent = wp_get_theme( get_template() );
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css', array(), $parent->get( 'Version' ) );
wp_enqueue_style(
'child-style',
get_stylesheet_uri(),
array( 'parent-style' ),
wp_get_theme()->get( 'Version' )
);
} );In Appearance, Themes, activate the child theme. Your site should look the same. If it looks unstyled, the parent stylesheet is not loading: some themes load their CSS from a different file or build step, so look at how the parent enqueues it. Some themes already enqueue their own stylesheet, and then the code above loads it twice. If the parent handle is already registered, depend on that handle instead of adding a new one.
A block (full site editing) theme needs even less. A child theme needs only a style.css with the Template header:
/*
Theme Name: MyBlockTheme Child
Template: myblocktheme
Version: 1.0.0
*/WordPress loads the parent's styles and theme.json automatically, and the child can add its own theme.json to override settings, such as colours, fonts and spacing. Set only what differs from the parent: WordPress merges it, so the child stays small. You normally do not need functions.php unless you register something. Copy a template or template part from the parent only when you need to change its markup.
One thing catches people out: edits made in the Site Editor are stored in the database against the active theme. If you switch from the parent to the child, you may need to review customizations made while the parent was active. Test before switching on a live site.
How do I override a template file?
Copy the file from the parent into the child folder, keeping the same relative path, and edit the copy. WordPress uses the child's version when it exists. For example, copy single.php or template-parts/content.php.
- Copy only what you change. Every copied file is something you must maintain.
- Never copy
functions.php. Both files load: the child's first, then the parent's. Add your own functions in the child, and use hooks and filters to alter parent behavior. - For WooCommerce templates, copy into
your-child-theme/woocommerce/and watch the template version notice in WooCommerce's status screen after updates.
A worked example: changing one template
Imagine a classic theme whose single post template shows the author name above the title, and you want it below.
- Find the file
A search in the parent theme's folder for
the_authororget_the_authorpoints totemplate-parts/content-single.php. - Copy it
Put it in the child at
template-parts/content-single.php, keeping the folder structure. - Edit the copy
Move the author line below the title.
- Reload a post
If nothing changes, a caching plugin or a different template (for example a custom post type's template) is in use.
- Leave a note
Write a comment saying what you changed and which parent version you copied it from.
That last step is cheap and saves the next person an hour. When the parent updates, compare against the version named in your comment.
How do I change a parent function safely?
Most well-built themes wrap functions in if ( ! function_exists( ... ) ), so a child can define its own version first. Others use filters and actions. Prefer, in this order: a filter, an action, a pluggable function, then a copied template. Never edit the parent. If you remove or replace something the parent adds, do it with remove_action or remove_filter at a later priority, after the parent has added it:
add_action( 'after_setup_theme', function () {
remove_action( 'wp_head', 'parent_theme_custom_meta', 10 );
}, 20 );The function name here is only an example; use the one your parent actually registers, which you can find by searching its code.
What do I check after a parent update?
- Read the changelog
Look for template changes in the parent's notes.
- Compare copied templates
Check each against the parent's new version and merge changes.
- Load key pages
Home, a post, a page, search, and the cart and checkout if it is a store.
- Check errors
Look at the PHP error log or turn on
WP_DEBUG_LOGon a staging copy.
This is the maintenance step people skip, and it is why a child theme is a safety net rather than a guarantee. A care plan covers updates with testing, and WordPress development is the right route if the customization is large enough to deserve a proper custom theme.
Troubleshooting
| Symptom | Likely cause | What to check |
|---|---|---|
| Child theme shown as "broken" | Template value does not match the parent folder | The parent's exact folder name |
| Site looks unstyled | Parent stylesheet is not enqueued | How the parent loads its CSS |
| Styles load twice | Parent already enqueues itself | Remove your duplicate enqueue |
| Menus and widgets vanished after switching | Settings are stored per theme | Re-assign menus and widget areas |
| A copied template shows old markup | A caching layer | Purge caches, reload |
| Fatal error after adding code | PHP syntax mistake | Debug log; undo the last change |
Should the code live in the child theme at all?
Appearance belongs in the theme and behaviour belongs in a plugin. If you find yourself adding a custom post type, a shortcode or an integration to the child's functions.php, move it to a small plugin. Then a future redesign does not make that feature disappear, and the code is easier to reuse and test.
What mistakes should I avoid?
Custom themes when a child is not enough.
WordPress theme development02Custom developmentPlugins, templates and integrations.
WordPress development03Care planUpdates with testing, cancel any time.
WordPress maintenanceA developer reads your brief, today.
Do I need a child theme if I only add custom CSS?
Not necessarily. Additional CSS in the Customizer or Site Editor is stored in the database and survives theme updates. Use a child theme when you change template files or add PHP.
Link to this answerShould I use @import to load the parent stylesheet?
No. @import makes the browser fetch styles one after another and slows the page. Enqueue the parent stylesheet with wp_enqueue_style, or, for a block theme, let WordPress load it.
Link to this answerWhat happens to my child theme when the parent updates?
Your child theme files are untouched. Check any template file you copied, because the parent's newer version may fix bugs or add features your copy lacks.
Link to this answerWhat must the Template header contain?
The exact folder name of the parent theme, not its display name. A misspelled value makes WordPress report the parent as missing and the child as broken.
Link to this answerShould I copy the parent's functions.php into the child?
No. Both files load, the child's first, then the parent's. Add your own functions in the child and use hooks and filters to change parent behavior.
Link to this answerWhere do WooCommerce template overrides go?
In a woocommerce folder inside your child theme. Watch the template version notice on WooCommerce's status screen after updates, because copied templates can fall behind.
Link to this answerDo I need functions.php in a block theme child?
Usually not. A block theme child needs only style.css with the Template header. WordPress loads the parent's styles and theme.json, and the child can add its own theme.json to override settings.
Link to this answerWhere should custom post types and shortcodes go?
In a small plugin, not the child theme. Appearance belongs in the theme and behavior in a plugin, so a future redesign does not make the feature disappear.
Link to this answerWhy does my parent stylesheet load twice?
Some themes already enqueue their own stylesheet. If the parent handle is already registered, depend on that handle in the child instead of adding a new enqueue.
Link to this answerCan I edit theme files in the dashboard editor?
It is risky, because a syntax error can take the site down with no undo. Disable it with DISALLOW_FILE_EDIT in wp-config.php and change code by SFTP or Git instead.
Link to this answerCan WP24x7 build a custom theme if a child theme is not enough?
Yes. When the customization is large enough to deserve a proper custom theme, theme development is the right route. Post a project with what you need and a developer will scope it.
Link to this answerKeep reading
Want an engineer on it?
Tell us what is wrong in plain words. A person reads it, today.