How to Create a WordPress Child Theme and When You Need One

A laptop with a vibrant colorful screen glowing on a dark wooden desk

A child theme lets you change how a WordPress theme looks or behaves without editing the theme itself. Your changes live in a separate folder, so they survive when the original theme is updated. This tutorial explains when a child theme is worth having and how to create one by hand in a few minutes.

What a child theme is

A child theme is a small theme that names another theme as its parent. WordPress loads the parent’s templates and functions and then applies whatever the child adds or overrides. The parent can be updated normally. The child keeps your modifications.

When you need one

  • You want to edit a theme’s template files or PHP.
  • You need to add functions that belong to the design, such as registering an extra image size.
  • You maintain a substantial amount of custom CSS that you want in a file under version control.
  • You want to override part of a parent theme, for example its footer.

When you do not

  • Small CSS changes. Use Additional CSS in the Customizer or the Styles panel of the Site Editor.
  • Block themes. Changes made in the Site Editor to templates, colours and fonts are stored in the database and survive updates without a child theme.
  • Functionality that is not about design. Custom post types, shortcodes or tracking code belong in a small plugin, so they remain if you change theme.
  • Settings the theme already offers. Check the theme options first.

Before you start

  • Access to the site files by SFTP or the host’s file manager.
  • A recent backup.
  • The folder name of the parent theme, as it appears in wp-content/themes. The name is case-sensitive.

Work on a staging copy if you can. See What Is a Staging Website and When Should You Use One?.

Step 1: Create the folder

In wp-content/themes, create a new folder. A common convention is the parent’s folder name followed by -child, for example parenttheme-child.

Step 2: Create style.css

Inside the folder, create a file named style.css with this header. Replace the values, and make sure Template exactly matches the parent’s folder name.

/*
 Theme Name: Parent Theme Child
 Template: parenttheme
 Version: 1.0.0
 Description: Child theme for our website.
*/

Theme Name and Template are the two required lines. Your own CSS goes below the header.

Step 3: Create functions.php

Create a file named functions.php in the same folder. Its job here is to load the stylesheets.

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

Some parent themes already load the child stylesheet themselves. If your styles appear twice or in the wrong order, check the theme’s documentation for its recommended child theme setup.

Unlike templates, the child’s functions.php does not replace the parent’s. Both run, with the child’s first.

Step 4: Activate

  1. In the dashboard, open Appearance, Themes.
  2. The child theme appears in the list. Activate it.
  3. Visit the site. It should look the same as before.

With classic themes, Customizer settings, menus and widgets are stored per theme, so you may need to reassign menu locations and widgets after activating the child.

Step 5: Add your changes

  • CSS: add rules to the child’s style.css.
  • Templates: copy the file you want to change from the parent into the child, keeping the same name and folder structure, then edit the copy. WordPress uses the child’s version.
  • Functions: add new functions to the child’s functions.php. Do not copy the parent’s entire functions file.
  • Block themes: a child can also contain its own theme.json, templates and parts folders, which override the parent’s.

Copy only the files you actually change. Every overridden template is one you must compare against the parent after each update.

Step 6: Test

  1. View several page types: home, a post, a page, an archive.
  2. Check on a phone.
  3. Confirm your CSS changes apply and the parent’s styles are still present.
  4. Look for errors in Tools, Site Health.

Troubleshooting

  • The child theme does not appear or is reported as broken: the Template line does not match the parent’s folder name exactly.
  • The site has no styling: the parent stylesheet is not being loaded. Check functions.php.
  • A white screen or critical error: there is a PHP syntax error in functions.php. Rename the child theme’s folder over SFTP to deactivate it, then correct the file.
  • Menus or widgets disappeared: reassign them under Appearance.

Maintaining a child theme

  • Keep the parent theme installed and updated. The child cannot work without it.
  • After a major parent update, compare the templates you overrode with the new originals.
  • Keep a copy of the child theme folder in your backups or in version control.

Next step

If you are still deciding how themes, plugins and content relate, read WordPress for Beginners: How the Main Parts Fit Together.