Skip to content
Technology for businesses since 2008

Help center · WordPress

How to create a WordPress child theme: step by step

A child theme is a small theme that inherits everything from another theme, the parent theme, and stores only your changes. To create one, you need a folder in wp-content/themes with a style.css whose header points to the parent (the Template field) and a functions.php that loads the parent’s styles. That way, you can update the parent theme without losing your modifications.

This article is for anyone who wants to change the CSS or code of an installed theme without losing their work at the next update. It covers what a child theme is, the minimum files it needs, how to activate it, and when you don’t need one.

What is a child theme, and why use one?

WordPress loads the parent theme and applies what’s in the child theme on top of it. If you edit the parent’s files directly, a theme update replaces them and your changes disappear. In a child theme, your changes live in a separate folder that the update doesn’t touch.

It’s worth it when you’ll change a lot of CSS, override a template file (such as footer.php), or add PHP functions to the theme.

Before you start

What files does a child theme need?

File Required? What it’s for
style.css Yes Header that identifies the theme and names the parent; also receives your CSS
functions.php In practice, yes Loads the parent’s CSS and holds your PHP code
Other templates (footer.php, single.php…) No If they exist in the child theme, they replace the file with the same name in the parent
screenshot.png No Preview image on the themes screen

The child theme’s functions.php does not replace the parent’s: both are loaded, and the child’s comes first. The child’s other template files, however, do replace the parent’s when they have the same name.

How to create a child theme, step by step

Step 1: create the child theme folder

In File Manager, open wp-content/themes and create a new folder, such as mytheme-child. Use lowercase letters, with no spaces or accents.

Step 2: create style.css with the header

Inside the new folder, create style.css, replacing mytheme with the name of the parent’s folder:

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

The field that makes the theme a child is Template, which must contain the parent’s folder name, not the name shown in the dashboard. If it’s wrong, WordPress reports that the parent theme wasn’t found. Your CSS goes below the header.

Step 3: create functions.php that loads the parent’s styles

In the same folder, create functions.php:

<?php
add_action( 'wp_enqueue_scripts', 'mytheme_child_styles' );

function mytheme_child_styles() {
    wp_enqueue_style(
        'mytheme-parent',
        get_template_directory_uri() . '/style.css'
    );
    wp_enqueue_style(
        'mytheme-child',
        get_stylesheet_uri(),
        array( 'mytheme-parent' ),
        wp_get_theme()->get( 'Version' )
    );
}

get_template_directory_uri() points to the parent and get_stylesheet_uri() points to the child’s style.css. With the dependency array( 'mytheme-parent' ), the child’s CSS loads afterward, so its rules win in case of conflict. Avoid @import in style.css: it’s an older method that slows down loading.

Don’t leave a blank line before <?php, and don’t close the file with ?>. A mistake here can cause a white screen or a 500 error; the steps to fix it are in 500 error or white screen on WordPress. If your theme has its own instructions for child themes, follow them, since some already load the parent’s CSS on their own.

Step 4: activate the child theme

  1. In the dashboard, go to Appearance > Themes.
  2. Click Activate on the child theme. The parent must remain installed.
  3. Open the site and check that the look stayed the same.

When you switch to the child theme, menus, widgets, and some Customizer options may seem to have disappeared, because many of them are stored per theme. Note them down or take screenshots beforehand, and redo them in the child theme, such as the menu locations under Appearance > Menus.

Step 5: make your changes in the child theme

  • CSS: in the child’s style.css, below the header.
  • Page template: copy the parent’s file to the child’s folder, with the same name, and edit the copy.
  • PHP function: in the child’s functions.php, never in the parent’s.

Make one change at a time and open the site after each one.

Do I need a child theme with block themes?

In many cases, no. In a block theme, changes made in the Site Editor (Appearance > Editor) are saved in the database, not in the theme’s files, so updating the theme usually doesn’t erase them. For small CSS adjustments, use the styles area of the editor or Additional CSS, if your dashboard has that option.

A child theme is still useful when you want to keep changes to files, such as theme.json, block patterns, or templates. It also needs the Template field, but each block theme loads its styles in its own way, so check your theme’s documentation before copying the functions.php above.

When isn’t a child theme the best option?

For a few CSS tweaks, use the Additional CSS option in the Customizer or the Site Editor. To add a function to the site, a plugin often solves the problem; see how to install a plugin in WordPress.

After creating the child theme

Keep updating the parent theme, with a copy of the site beforehand, following how to update WordPress, themes, and plugins safely. If you overrode the parent’s templates, compare them with the new version after each update, because the file in the child theme doesn’t receive the parent’s fixes. If you need help, get in touch with MigraCloud.

Frequently asked questions

What is a child theme in WordPress?

It’s a theme that inherits the files and look of another theme, the parent, and stores only your modifications. It needs the parent theme installed in order to work. It’s used to customize the site without the parent’s updates erasing your changes.

How do I create a child theme without a plugin?

Create a folder in wp-content/themes, add a style.css with Theme Name and Template (pointing to the parent’s folder), and add a functions.php that loads the parent’s CSS. Then activate it under Appearance > Themes. There are plugins that automate this, but the manual process is simple.

What should I put in the Template field of style.css?

The exact name of the parent theme’s folder inside wp-content/themes, respecting uppercase and lowercase letters. It isn’t the display name shown in the dashboard. If it’s wrong, WordPress says the parent theme wasn’t found.

Can I delete the parent theme after creating the child theme?

No. The child theme uses the parent’s files and stops working without it. Even when the parent isn’t active, it must remain installed in the themes folder.

When I activated the child theme, my menu and settings disappeared. Is that normal?

It can happen, because several Customizer settings and menu locations are stored per theme. Redo them in the child theme. That’s why it’s worth noting or photographing your settings before switching.

Does a block theme need a child theme?

Usually not to customize the look, because Site Editor changes are stored in the database. A child theme is useful if you want to keep changes to theme files, such as theme.json and templates.

More on WordPress

See all →

Help center

Looking for something else?

See all tutorials, organized by topic.