Site icon Impact Digital

WordPress Child Themes: When You Need One and How to Make It

Diagram of a WordPress parent theme folder and a child theme folder with style.css and functions.php

This guide is for bloggers, agency owners and small-business site owners who want to change how a WordPress theme looks or behaves and are wondering whether they need a child theme. The short answer: sometimes. Below you will see when a child theme is worth the effort, how to build one for a classic theme and for a block theme, when to skip it, and which mistakes cause the most trouble.

What a child theme is and why people use one

According to the WordPress Theme Handbook, a child theme extends a parent theme so you can modify it without editing the parent’s files. The child inherits the parent’s design and functionality, and you write only the code that differs. The handbook lists these benefits:

The same handbook page gives a limit: only two levels exist, parent and child. Grandchild themes are not currently possible. It also warns that very heavy customization inside a child theme can become hard to manage, and that for large projects forking the original theme into a standalone parent may be the better call. That decision is made case by case.

Do you actually need one?

A child theme is for changes that live in theme files: PHP functions, template files, or a stylesheet you want under version control. It is usually unnecessary for light tweaks.

Your goalLikely best approach
A few CSS tweaks (button colour, spacing)Additional CSS in the Customizer (classic themes) or the Site Editor’s style options (block themes). No child theme needed.
Visual changes on a block theme: colours, fonts, template editsEdit in the Site Editor. These edits are stored in the database as user customizations.
Custom PHP functions or hooksChild theme functions.php (or a small plugin if the code is not theme-specific).
Rewriting parent template files in a classic themeChild theme with copies of those templates.
Changes so extensive that you override most of the parentConsider forking the parent into your own standalone theme, as the handbook suggests.

Where Additional CSS appears in the dashboard depends on your WordPress version and whether you use a classic or block theme, so look for it in your own admin area. One caution that applies either way: customizations stored in the database are separate from theme files, so decide deliberately where each change lives and keep a note of it.

Creating a classic child theme

The handbook describes the process in three parts: a folder, a style.css file, and installation.

Step 1: Create the folder

In wp-content/themes, create a folder named with the kebab-case version of your theme name. The handbook’s example theme, “Grand Sunrise”, becomes grand-sunrise.

Step 2: Add style.css with a Template header

style.css is the only strictly required file. It must start with a file header containing the standard required fields, plus a Template field that marks the theme as a child:

/**
 * Theme Name: Grand Sunrise
 * Template:   twentytwentyfour
 */

The Template value must exactly match the parent theme’s folder name inside wp-content/themes, not its display name. For Twenty Twenty-Four the folder is twentytwentyfour.

Step 3: Install and activate

If the folder is not already on the server, zip it and upload it under Appearance > Themes > Add New, then activate it from Appearance > Themes. At first it will look identical to the parent because nothing is customized yet.

Step 4: Load styles in functions.php if needed

Whether you need this step depends on the parent. The handbook says to check the parent’s code, because there are no universal rules, and describes three cases:

The handbook’s pattern for enqueueing the child stylesheet looks like this (rename the function and handle to match your theme):

add_action( 'wp_enqueue_scripts', 'grand_sunrise_enqueue_styles' );

function grand_sunrise_enqueue_styles() {
	wp_enqueue_style(
		'grand-sunrise-style',
		get_stylesheet_uri()
	);
}

For the parent’s file, the handbook uses get_parent_theme_file_uri( 'style.css' ) in the same kind of function.

How functions.php and templates behave

Child themes for block themes

Block themes work a little differently. The handbook says loading style.css is often unnecessary for block themes, since they handle styling mainly through theme.json, which the theme handbook describes as the file used for configuring colours, default typography and front-end styles. A block child theme can still add or override templates, template parts and patterns by using matching file names.

The handbook also describes how the layers stack on the front end: WordPress’s default theme.json, then the parent theme, then the child theme, then user customizations. Those user customizations behave like a grandchild layer, except they are stored in the database rather than in files. This matters in practice: if you have already changed styles in the Site Editor, those changes sit on top of whatever the child theme defines.

Using the Create Block Theme plugin

You can write the files by hand, or use the Create Block Theme plugin from WordPress.org. Per its plugin page, it can create a blank theme, clone the active theme with your changes, create a child theme of the active parent, create a style variation, export a theme as a zip, and save user-changed templates and styles to the active theme. After you install and activate it, a panel opens from an icon beside the Save button in the Editor. Choose the “Create Child Theme” option there.

Check these points before you use it:

Test on staging first

Activating a child theme switches the live theme, so do it on a copy of the site. Our walkthrough on using a WordPress staging site before you update covers the setup. Our guide to automatic off-site WordPress backups explains how to keep a restore point in case something breaks. After activating on staging, check the home page, a post, an archive, search and the checkout or contact form if you have one, and confirm the front end still shows your custom styles.

Common mistakes

  1. Using the theme’s display name in Template. It must be the parent’s folder name.
  2. Copying the parent’s functions.php. Duplicate function names produce fatal errors. Only add your own code.
  3. Assuming styles load automatically. Check how the parent enqueues stylesheets before deciding whether you need an enqueue function.
  4. Editing the parent directly. Changes in parent files are lost on update, which is the problem child themes exist to solve.
  5. Forgetting database customizations. On block themes, Site Editor edits live in the database, so a child theme’s files may not behave as expected until you review them.

If you are still deciding which theme to start from, our piece on free and premium WordPress themes compares the options.

Key takeaways

FAQ

Will updating the parent theme break my child theme?

The handbook says the parent can be updated without losing your changes. That said, overridden templates are copies, so review them after a major parent update to see whether the parent’s versions changed.

Can I create a child of a child theme?

No. The handbook states grandchild themes are not currently possible, and there is no standard method for an installable grandchild theme.

Do I need a child theme for a block theme?

Not for most visual changes. The Site Editor stores your customizations in the database. A child is useful if you want file-based changes you can move between sites or keep in version control.

Why do my child theme styles not appear?

Check how the parent loads stylesheets. If it loads none, the handbook says to enqueue the child’s stylesheet in functions.php. Also confirm the Template header matches the parent’s folder name.

Sources

Exit mobile version