Guides

WordPress Child Themes Explained: What They Are, When You Need One and How to Create One (With Code)

A WordPress child theme lets you change a theme without losing edits on update. Learn when you need one, how to create it in code and how to switch safely.

WordPress Child Themes Explained: What They Are, When You Need One and How to Create One (With Code)
On this page
  1. How a child theme works
  2. When you need a child theme, and when you don't
  3. How to create a child theme step by step
  4. Before you switch a live site to a child theme
  5. Moving existing edits out of the parent theme
  6. Overriding template files
  7. Child themes for block themes
  8. Child themes with Elementor and other builders
  9. Common child theme problems and fixes
  10. Keeping the child theme in version control
  11. The quicker way: WP-CLI or a generator
  12. Will a child theme slow down my site?
  13. What happens when the parent theme updates
  14. Back up the child theme separately
  15. Quick check: do you need a child theme?
  16. When to get help
  17. FAQs
Key takeaways
  • A child theme inherits everything from its parent and holds only your changes, so parent theme updates no longer wipe your custom code.
  • You need one only for template, PHP or substantial CSS changes; small CSS tweaks and snippets can live in Additional CSS or a code snippets plugin.
  • Create it with a style.css header and a functions.php that loads the parent styles, then test the switch on staging because menus and widgets may need reassigning.

A WordPress child theme is a small theme that inherits all the design and features of a parent theme while holding only your own changes, so you can update the parent without losing your custom code. You need one when you edit theme template files or functions.php; to create it, you add a folder with a style.css header naming the parent and a functions.php that loads the parent's stylesheet, then activate it.

Below is when a child theme is worth it, the exact files to create, how to switch a live site safely, and how the idea works with block themes and page builders.

How a child theme works

WordPress looks for each template file in the active child theme first. If it is not there, it uses the parent's version. The child's functions.php loads in addition to the parent's (before it, in fact), so you can add features without copying the parent's code. Stylesheets can be layered so your CSS overrides the parent's.

The result: when the theme developer releases an update, the parent folder is replaced, but your child folder is untouched. That is the whole point. Editing the parent directly means every update silently erases your work, which is one of the most common reasons we see "my site changed after an update" calls, alongside the issues in updating a premium theme safely.

When you need a child theme, and when you don't

Change you wantChild theme needed?Better place
A few lines of CSSNoCustomizer Additional CSS or the Site Editor's custom CSS
A small PHP snippet (e.g. change excerpt length)OptionalA code snippets plugin or a small site plugin
Editing template files such as header.php or single.phpYesChild theme
Overriding WooCommerce templatesYesChild theme's woocommerce folder
Adding custom post types or business logicNoA plugin, so it survives a theme change
Design changes in Elementor or the block editorNoStored in the database, safe on update

The last two rows matter. Functionality that should outlive the design, such as a custom post type, belongs in a plugin. Our article on plugin vs custom code explains where each kind of change should go.

How to create a child theme step by step

Work on a staging copy or with a fresh backup. Then:

  1. Find the parent theme's folder name in wp-content/themes, for example astra or generatepress. This is the Template value, and it must match exactly.
  2. Create a new folder next to it, for example astra-child.
  3. Inside it create style.css with this header:
/*
Theme Name: Astra Child
Template: astra
Version: 1.0.0
Description: Child theme for site customisations
*/
  1. Create functions.php to load the parent and child styles:
<?php
add_action( 'wp_enqueue_scripts', function () {
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    wp_enqueue_style( 'child-style', get_stylesheet_uri(), array( 'parent-style' ), wp_get_theme()->get( 'Version' ) );
} );
  1. Optionally add a screenshot.png (1200 by 900 pixels) so it is easy to recognise in Appearance, Themes.
  2. Zip the folder and upload it from Appearance, Themes, Add New, or upload it by FTP or the hosting file manager.
  3. Activate it on staging and check the site.

Some themes load their own stylesheet in a different way, so the parent style line may already be handled. If the site looks doubled or styles load twice, check the parent theme's documentation; many popular themes provide a ready-made child theme download, which is the safest starting point.

Before you switch a live site to a child theme

WordPress treats the child as a different theme, so some settings stored per theme do not carry across automatically:

  • Menu locations may need reassigning in Appearance, Menus.
  • Customizer settings (colours, logo, layout options) may reset; many themes offer an export and import tool for these.
  • Widgets in classic themes may move to inactive widgets.
  • Caching and CSS optimisation plugins need their cache cleared.

Make a list of the current settings, switch on staging, compare page by page, then repeat on live at a quiet hour. Our guide to staging sites covers how to push the result live.

Moving existing edits out of the parent theme

If someone already edited the parent theme directly, do not update it yet. First find what changed. Download a fresh copy of the same parent version and compare folders with a diff tool, or ask the developer who made the edits. Then:

  • Move CSS changes into the child's style.css.
  • Move added functions into the child's functions.php (or a plugin).
  • Copy edited template files into the child at the same path.

Only then update the parent. If you skip this step, the update deletes the edits and you are left rebuilding from memory, which is also why we ask for this during a website handover.

Overriding template files

To change a template, copy it from the parent to the same relative path in the child and edit the copy. For WooCommerce, copy files from the plugin's templates folder into a woocommerce folder in your child theme.

Keep overrides to a minimum. Every copied file is frozen at the version you copied, so when the parent or WooCommerce improves that template, your site does not get the improvement. WooCommerce shows outdated template overrides in WooCommerce, Status; check it after each major update. Where possible, use hooks and filters in functions.php instead of copying whole templates.

Child themes for block themes

Block themes such as Twenty Twenty-Four and many modern themes work with child themes too. The child can contain its own theme.json (which merges with the parent's), templates and template parts as HTML files, and patterns. Changes made in the Site Editor are saved in the database, not in files, so they already survive updates; a child theme is mainly useful when you want those changes stored in code for version control. The Create Block Theme plugin can export Site Editor changes into a child theme for you. See block themes and full site editing for the wider picture.

Child themes with Elementor and other builders

Elementor, Divi and similar builders store page designs in the database, so a child theme is not needed for page content. It is still useful for custom PHP, extra fonts or code that hooks into the builder. Hello Elementor has an official child theme for this. If you are choosing a base theme, see our notes on how to choose a WordPress theme.

Choosing between a builder and blocks changes how much a child theme matters. See Gutenberg vs Elementor for how each approach handles design.

If an edit to the child theme appears to do nothing, caching or a different template is usually the cause. Work through why WordPress changes are not showing on your website.

Common child theme problems and fixes

  • "The parent theme is missing": the Template line does not match the parent folder name exactly, including case.
  • Styles not changing: a cache or optimisation plugin is serving old CSS; clear it and bump the Version number in style.css. Our guide to CSS changes not showing has more fixes.
  • White screen after activation: a PHP error in functions.php, often a missing semicolon or a duplicate function name. Rename the child folder by FTP to fall back to the parent, then fix the code.
  • Layout looks broken: parent styles are not loading, or loading twice; check the enqueue code against the theme's documentation.

If you need a child theme set up properly or custom edits rescued from a parent theme before an update, I handle this under WordPress maintenance and support, or you can hire a WordPress developer in India for a one-off fix.

Keeping the child theme in version control

Because the child theme now holds your custom code, treat it like code. Keep it in a Git repository, note each change in a short changelog, and deploy it through staging. If you ever hand the site to another developer, the repository shows exactly what was customised and why.

The quicker way: WP-CLI or a generator

If your host offers SSH, WP-CLI can create the child theme for you with a single scaffold command naming the parent folder; it writes the folder, style.css and functions.php. Several themes also offer a child theme download in their documentation or dashboard, and small generator plugins can create one from the admin. Generator plugins are fine to use once: create the child, check the files, then remove the plugin.

Will a child theme slow down my site?

Not in any noticeable way. WordPress checks one extra folder for templates, and the child adds one small stylesheet. The only real cost comes from mistakes, such as loading the parent stylesheet twice or importing it with an @import rule in CSS, which delays rendering. Enqueue styles in functions.php as shown above and the impact is negligible.

What happens when the parent theme updates

The parent folder is replaced and your child folder stays as it is. Your CSS and functions keep working in most cases. Two things can still go wrong: a template file you copied into the child may now be outdated compared with the new parent version, and a parent function or hook you rely on may be renamed or removed. Read the parent's changelog, update on staging first, and compare any overridden templates. A child theme cannot have its own child theme, so if you need another layer of customisation, use a plugin for it.

Back up the child theme separately

Most backup plugins include the themes folder, but check that yours does. Also keep a downloaded copy of the child theme folder, or better, keep it in Git, so that if the site is ever hacked or rebuilt, your customisations can be restored in minutes instead of being recreated from scratch.

Quick check: do you need a child theme?

  1. See what is active: go to Appearance, Themes. If the active theme's description says it is a child of another theme, you already have one.
  2. Check for edits: open Appearance, Theme File Editor (or the theme folder via your file manager) and look for custom code in functions.php or style.css of the parent theme. Those edits will be lost on update.
  3. Check where CSS lives: look in Appearance, Customize, Additional CSS. CSS saved there survives theme updates, so small style tweaks may not need a child theme at all.

The theme under Elementor matters as well; see the best theme for Elementor compared.

When to get help

Get help when someone has edited the parent theme directly, when you need template changes beyond CSS, or when switching to a child theme might reset your Customizer settings. WordPress website development covers clean child theme setup, WordPress maintenance keeps theme updates safe, and Elementor development helps with page-builder themes. Get in touch with your theme name.

FAQs

What is a child theme in WordPress?

It is a theme that inherits the design and functions of a parent theme and stores only your changes. Updating the parent no longer overwrites your custom code.

Do I need a child theme for small CSS changes?

No. Use Additional CSS in the Customizer or custom CSS in the Site Editor. A child theme is worth it when you edit template files, functions.php or WooCommerce templates.

How do I create a child theme in WordPress?

Create a folder, add a style.css with Theme Name and Template lines, add a functions.php that enqueues the parent stylesheet, then upload and activate it. Test on staging first.

Will I lose my settings when I activate a child theme?

Some theme settings, menu locations and widgets can reset because WordPress treats the child as a new theme. Export Customizer settings first and reassign menus after switching.

Can I use a child theme with Elementor?

Yes. Elementor pages are stored in the database, so they work the same. A child theme of Hello Elementor is useful for custom PHP or extra code.

Do block themes need child themes?

Not for changes made in the Site Editor, because those are saved in the database. A child block theme helps when you want templates and theme.json changes kept in code.

Need help with your website?

I'm a freelance WordPress developer building fast, SEO-friendly websites since 2020. Tell me what you need and I'll reply with a plan and a fixed quote, usually within 24 hours.

Found this useful? Share it:
Contact

Let's build your next website

Available for freelance projects, agency white-label work and long-term maintenance. Feel free to pass this along to your team or company.

I reply within 24 hours, usually the same day. Your details are emailed to me, then WhatsApp opens so we can chat right away.

Chat now