Guides

WordPress Child Themes Explained: What They Are and How to Create One

What a WordPress child theme is, why customisations belong in one, how to create a child theme (style.css header, functions.php, template overrides), and when you don't need one.

WordPress Child Themes Explained: What They Are and How to Create One
On this page
  1. What a child theme is
  2. When you need one
  3. When you don't
  4. How to create one
  5. Overriding templates
  6. Block themes
  7. Switching an existing site to a child theme
Key takeaways
  • A child theme keeps customisations safe from parent theme updates.
  • Create a folder with style.css (naming the parent in Template) and functions.php.
  • Put functionality in a plugin instead, and test the switch to a child theme on staging.

If anyone has ever edited your theme's files directly, the next theme update will wipe those changes out. A child theme solves this: it holds your customisations separately, so the parent theme can be updated safely.

What a child theme is

A child theme is a small theme that inherits everything from a parent theme and only overrides what you change. WordPress loads the child theme's files first, falling back to the parent for everything else.

When you need one

  • Adding custom PHP functions to the theme
  • Overriding theme template files
  • Adding significant custom CSS

When you don't

  • Small CSS tweaks can go in the Customizer's Additional CSS or your page builder's custom CSS
  • Site-wide functionality (not design) is better in a small custom plugin; see plugin vs custom code
  • Sites built entirely in a page builder with no code changes

How to create one

  1. Create a new folder in wp-content/themes, for example astra-child
  2. Add a style.css file with a header naming the parent theme's folder in the Template line:
    /*
    Theme Name: Astra Child
    Template: astra
    */
  3. Add a functions.php file. For many classic themes, use it to load the parent theme's stylesheet with WordPress's enqueue functions (check your parent theme's documentation, as some load it automatically)
  4. Activate the child theme in Appearance → Themes

Many popular themes also offer a ready-made child theme or a generator tool.

Overriding templates

To change a template, copy the file from the parent theme into the same path in the child theme and edit the copy. After parent updates, check whether the original template changed significantly.

Block themes

Block themes can have child themes too, with their own theme.json for style changes and HTML templates; see block themes explained.

Switching an existing site to a child theme

Activating a child theme can reset some theme customiser settings and menu locations. Test on staging, note your settings first and move any direct edits from the parent into the child; see updating premium themes safely.

Need help with your website?

I'm Sameer, 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 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.

Your details are emailed to me, then WhatsApp opens so we can chat right away.

Chat now