How to Create a Child Theme in WordPress

Setting up a WordPress child theme in two files

When you customise a WordPress theme by editing its files directly, every update overwrites your changes. A child theme solves this: it inherits all the styles and templates of the parent theme while letting you safely override only what you need.

Problem: How do you customise a WordPress theme without losing your changes every time the theme updates?

Solution: A child theme requires just two files. Create a new folder inside /wp-content/themes/ — for example, mytheme-child — and add these files to it.

style.css — must include the Template header pointing to the parent theme's folder name:

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

functions.php — enqueue both the parent and child stylesheets in the correct order:

add_action( 'wp_enqueue_scripts', 'child_theme_enqueue_styles' );

function child_theme_enqueue_styles() {
    $parent = 'mytheme-style'; // parent theme's main stylesheet handle

    wp_enqueue_style( $parent,
        get_template_directory_uri() . '/style.css'
    );
    wp_enqueue_style( 'mytheme-child-style',
        get_stylesheet_directory_uri() . '/style.css',
        [ $parent ],
        wp_get_theme()->get( 'Version' )
    );
}

After saving both files, go to Appearance → Themes, activate your child theme, and you're good to go.

NOTE: To override a parent template — say, single.php — simply copy it into your child theme folder and edit it there. WordPress automatically uses the child theme's version first.