# How to set up a WordPress child theme, and why

URL: https://wp24x7.com/how-to-properly-set-up-child-theme/
Updated: 2026-11-29
Type: blog post
Audience: WordPress site owners and developers

> 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.

## Key facts

- 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

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.**

> **Quick answer**
Create `mytheme-child/style.css` with a `Template:` header naming the parent's folder, enqueue the parent styles in `functions.php` (classic theme only), activate it, and put every change there. Back up first.

## 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 |

_A child theme sits beside the parent and overrides only what you change_

## 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.

### Classic theme
Inside the folder, create `style.css`:

```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
<?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.
### Block theme
A block (full site editing) theme needs even less. A child theme needs only a `style.css` with the `Template` header:

```css
/*
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.

1. **Find the file.** A search in the parent theme's folder for `the_author` or `get_the_author` points to `template-parts/content-single.php`.
2. **Copy it.** Put it in the child at `template-parts/content-single.php`, keeping the folder structure.
3. **Edit the copy.** Move the author line below the title.
4. **Reload a post.** If nothing changes, a caching plugin or a different template (for example a custom post type's template) is in use.
5. **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:

```php
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?

1. **Read the changelog.** Look for template changes in the parent's notes.
2. **Compare copied templates.** Check each against the parent's new version and merge changes.
3. **Load key pages.** Home, a post, a page, search, and the cart and checkout if it is a store.
4. **Check errors.** Look at the PHP error log or turn on `WP_DEBUG_LOG` on 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](/wordpress-maintenance-service) covers updates with testing, and [WordPress development](/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?

> **Common mistakes**
Using a premium theme's demo import before creating the child, since some themes store settings per theme. Putting a child theme inside the parent folder, when it must sit beside it. Misspelling the `Template` value. Editing files in the dashboard's theme editor: a syntax error there can take the site down, and you cannot undo it. Disable it with `define( 'DISALLOW_FILE_EDIT', true );` in `wp-config.php`. Our post on the [File Manager plugin flaw](/avoid-file-manager-plugin-critical-security-flaw) explains why.

- **Theme development** Custom themes when a child is not enough. [WordPress theme development](/wordpress-theme-development)
- **Custom development** Plugins, templates and integrations. [WordPress development](/wordpress-development)
- **Care plan** Updates with testing, cancel any time. [WordPress maintenance](/wordpress-maintenance-service)

**Want a theme customized properly?**
A developer reads your brief, today.
[Post a project](/post-project)
[Call the help desk](/help-desk)

## Frequently asked questions

### 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.

### Should 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.

### What 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.

### What 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.

### Should 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.

### Where 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.

### Do 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.

### Why did my menus and widgets vanish after activating the child?

Menu locations and widget areas are stored per theme. Re-assign them after switching, and test on a staging copy before switching a live site.

### Where 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.

### Why 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.

### Can 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.

### Can 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.
