Guide WordPress

How to set up a WordPress child theme

The small amount of setup that lets you customise a theme without losing every change the next time it updates.

Updated 7 min read Intermediate

Edit a WordPress theme's files directly and the next update to that theme overwrites every change you made, without warning and without asking. A child theme exists to solve exactly this: it is a small, separate theme that inherits everything from a parent theme while letting you override specific pieces, and it is untouched when the parent updates.

What a child theme actually is

Structurally, it is just another folder in wp-content/themes, with a minimum of two files: style.css and functions.php. WordPress loads the parent theme's templates and styles as normal, then lets the child theme override anything it defines itself. A child theme with nothing in it beyond the two required files behaves identically to its parent — the point is that you can now add to it safely.

Not every theme supports being a parent

Any properly built theme can have a child, since the mechanism is a core WordPress feature rather than something the parent theme has to implement. Themes built entirely around a separate page-builder plugin are the exception — most of the customisation there happens in the builder's own interface, not in theme template files, so a child theme has less to protect.

Building the child theme

  1. Create the folder

    Inside wp-content/themes, create a new folder. Name it after the parent with -child appended — for a parent folder named twentytwentyfour, use twentytwentyfour-child. The name itself does not matter to WordPress, but a clear one saves confusion later.

  2. Create style.css with the required header

    This is what tells WordPress the theme exists and which parent it belongs to:

    /*
     Theme Name:   Twenty Twenty-Four Child
     Template:     twentytwentyfour
     Version:      1.0.0
    */

    The Template line has to match the parent theme's folder name exactly, character for character. This is the single most common mistake when setting one up — a typo here, or a value that points at the wrong folder, and WordPress cannot find the parent, leaving the child theme broken or invisible in the theme list.

  3. Create functions.php to load both stylesheets

    A child theme's own style.css is not loaded automatically the way a parent's is — you need to enqueue both stylesheets, parent first:

    <?php
    add_action( 'wp_enqueue_scripts', 'ifh_enqueue_child_styles' );
    function ifh_enqueue_child_styles() {
        wp_enqueue_style(
            'parent-style',
            get_template_directory_uri() . '/style.css'
        );
        wp_enqueue_style(
            'child-style',
            get_stylesheet_directory_uri() . '/style.css',
            array( 'parent-style' ),
            wp_get_theme()->get( 'Version' )
        );
    }

    Note the two different functions: get_template_directory_uri() always points at the parent, and get_stylesheet_directory_uri() always points at the active theme — the child, once it is activated. Mixing these up is the second most common mistake, and the symptom is a site that loads without any child theme styling applied.

  4. Activate it

    In Appearance → Themes, the child theme now appears as its own entry. Activate it, not the parent. Any widgets, menus and customiser settings tied to the parent generally carry over, but check the site afterwards in case anything theme-specific needs re-selecting.

Overriding a template file

To change a specific part of the theme — the header, a single page template, the footer — copy that file from the parent theme's folder into the same relative location in the child theme, then edit the copy. WordPress checks the child theme first for any file it needs and only falls back to the parent if the child does not have its own copy, so the child's version takes over automatically.

Copy the whole file, then edit

Do not try to write a template file from scratch based on what you think it should contain. Copy the parent's actual file across first, so you start from something that already works, and make your changes from there.

Adding your own PHP

functions.php in a child theme is not a replacement for the parent's — both run, with the child's loading first. This makes it the right place for small customisations: adding a shortcode, adjusting an existing hook, registering an extra menu location. Anything you add here survives parent theme updates completely, which is the entire point of having gone through this setup.

After it is set up

Test the site properly once the child theme is active — check the front end, check the admin area still shows the theme customiser working, and check any page templates you use regularly still render as expected. From here, parent theme updates are safe to install without a second thought, and updating WordPress without breaking your site covers the rest of what to check before any update.

Frequently asked questions

Does a child theme slow the site down?

No. WordPress loads it exactly like any other theme, and the extra stylesheet is a single small file. The performance of a child theme is the performance of its parent theme.

Can I use a child theme with a page builder?

Yes, and it is still worth using one for the reason it exists at all: protecting anything you customise at the theme level, such as template files or the functions.php file, from being wiped out on update. A page builder's own content is usually stored separately and is not affected either way.

Related reading