Tutorial · wordpress · Published 2026-08-16 · 3 min read

Create a WordPress child theme

Create a WordPress child theme: the functions.php and style.css setup, why overrides stay safe, and update discipline.

Why a child theme

A child theme is a theme that explicitly inherits from a parent theme. It lets you override styles and template files in one place while the parent theme still provided the base. When you edit a theme directly, a theme update overwrites your changes. A child theme keeps the customization separate from the parent, so updating the parent does not erase your edits.

The best time to split is before you start editing, not after the theme is already customized. Anything you have already changed in the parent has to be re-created in the child, so starting a child early pays off.

The two required files

A child theme needs only a directory, a style.css, and a functions.php. Create a directory under /wp-content/themes/ (for example mytheme-child) that should match the naming that WordPress expects, then add two files.

style.css carries the header that tells WordPress the theme is a child of the parent:

/*
Theme Name: My Theme Child
Template: mytheme
*/

The Template: line must match the parent theme's folder name exactly. Add a @import-free enqueue in functions.php, which is the recommended way instead of @import because the stylesheet and its dependencies load at the right point:

add_action( 'wp_enqueue_scripts', function() {
    wp_enqueue_style(
        'mytheme-parent',
        get_template_directory_uri() . '/style.css'
    );
    wp_enqueue_style(
        'mytheme-child',
        get_stylesheet_directory_uri() . '/style.css',
        array( 'mytheme-parent' )
    );
} );

After that, activate the child theme in Appearance > Themes and confirm the site styles match the parent.

Keep the overrides safe

AlternativeChange survives parent update?Note
Edit parent theme directlyNoOverwritten on update
Child theme overrideYesRecommended
Plugin with hooksYesBest for function-level tweaks

The WP-CLI theme activation guide shows how to switch to the child theme from the command line, and if a change lands wrong, the troubleshooting order is where to start instead of editing files blindly. When a child theme breaks a page, the cause is often a theme conflict of the same kind covered under plugin-caused errors, so follow the same isolation steps.

Need a website built, fixed, optimised, migrated or replaced?

This technical resource is written by CSMBAC, a small design and development studio. If you would rather hand the problem to a professional, the website service page explains how we build enquiry-ready websites.

Explore website services