WP Tuts Hub

Browse

  • Home
  • Categories
    • WordPress & AI
    • WordPress Security
    • WordPress Troubleshooting
    • WordPress Tips and Tricks
    • Series Tutorials
  • WordPress Tools
    • Inside WordPress
    • All tools
    • Error decoder
    • Redirect tester
    • URL replace
    • wp-config helper
    • Plugin Suggestor (AI)
    • Snippet Studio
    • Permalinks builder
    • Conflict triage
    • Log decoder
    • More free tools
  • My Plugins
  • Contact Me
  • About WP Tuts Hub
Home/WordPress Development/Create a WordPress Child Theme Step by Step
WordPress Development
By Md. Zubaer Ahammed Published December 5, 2026

Create a WordPress Child Theme Step by Step

  • Child Themes
  • style.css
  • theme.json
  • wp_enqueue_style
  • WP-CLI
Create a WordPress Child Theme Step by Step

To create a WordPress child theme you need two files in a new folder under wp-content/themes/: a style.css whose header names the parent, and a functions.php that enqueues the parent stylesheet before the child’s. Point Template: at the parent’s folder name, activate the child under Appearance → Themes, and everything you add stays put when the parent ships an update.

That is the whole trick. The parts people get wrong are the header field that has to be a folder slug rather than a theme name, the load order of the two stylesheets, and what happens to Customizer settings and menu locations the moment you switch.

What is the smallest child theme WordPress will accept?

One file. A style.css with a valid header is enough for WordPress to list the theme and let you activate it. functions.php is optional, and so are index.php, screenshot.png and the rest of what you may have seen in a tutorial. A child theme is not a standalone theme, so it does not need the template files a standalone theme needs. WordPress falls back to the parent for anything the child does not provide.

Create the folder and the stylesheet:

/*
Theme Name: Twenty Twenty-Five Child
Theme URI: https://example.com/twentytwentyfive-child
Description: Child theme for Twenty Twenty-Five. Custom styles and hooks live here.
Author: Site Team
Author URI: https://example.com
Template: twentytwentyfive
Version: 1.0.0
Requires at least: 6.7
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: twentytwentyfive-child
*/

The Template: line is the one doing the work. It must match the parent theme’s directory name exactly, which is the slug you see in wp-content/themes/, not the name shown in the admin.

Which header fields actually change behaviour?

Most of the header is decoration. These fields are read by code:

  • Theme Name and Template are required. If Template names a folder that does not exist, the theme drops out of the grid in Appearance → Themes and is listed under Broken Themes at the bottom of that screen, with the message “The parent theme is missing”.
  • Version is what wp_get_theme()->get( 'Version' ) returns. Use it as the cache-busting argument when you enqueue the child stylesheet, then bump it on every deploy.
  • Text Domain is the handle for load_child_theme_textdomain(). Keep it equal to the folder name.
  • Requires at least and Requires PHP stop the Themes screen from activating the child on an older install. Twenty Twenty-Five itself needs WordPress 6.7, so the child should not claim less. WP-CLI does not make this check: on the test site wp theme activate switched to a child that asked for a WordPress version that does not exist.

Description, Author, License and Theme URI are shown on the theme card and nowhere else. Fill them in for the person who inherits the site, but they will not change how anything runs.

Warning if the child theme is missing from the grid in Appearance → Themes, scroll down to Broken Themes. A Template value that holds the parent’s display name instead of its folder name is the usual reason it lands there.

Advertisement

How do you enqueue the parent and child stylesheets in the right order?

The child’s style.css has to load after the parent’s, otherwise your overrides lose to the parent’s rules at equal specificity. You do not control that with hook priority. You control it with the dependency array.

First find out whether the parent already enqueues its own stylesheet, because most themes do. Open the parent’s functions.php, find its wp_enqueue_style() call and note the handle. Twenty Twenty-Five enqueues its stylesheet as twentytwentyfive-style, so the child only has to add its own file and name that handle as a dependency:

<?php
/**
 * Load the child stylesheet after the parent's.
 * Twenty Twenty-Five already enqueues its own file as 'twentytwentyfive-style'.
 */
add_action( 'wp_enqueue_scripts', function () {
	wp_enqueue_style(
		'child-style',
		get_stylesheet_uri(),
		array( 'twentytwentyfive-style' ),
		wp_get_theme()->get( 'Version' )
	);
} );

array( 'twentytwentyfive-style' ) tells WordPress that child-style cannot be printed until the parent’s stylesheet is. The dependency is resolved when the styles are printed, and that matters here: the child’s functions.php runs before the parent’s, so child-style is queued first and only the dependency moves it into second place.

Passing the theme version as the fourth argument appends ?ver=1.0.0 to the URL. Without it, browsers and page caches keep serving the old stylesheet after you edit it, and you spend twenty minutes wondering why your CSS did not apply.

WordPress prints the parent’s stylesheet first, then the child’s (test site: WordPress 7.1.3, PHP 8.2):

twentytwentyfive-style
child-style

If the parent enqueues nothing at all, which you will mostly see in older classic themes, enqueue both files yourself:

<?php
/**
 * Load the parent stylesheet first, then the child stylesheet on top of it.
 * Only for parents that do not enqueue their own style.css.
 */
add_action( 'wp_enqueue_scripts', function () {
	$parent = get_template();

	wp_enqueue_style(
		'parent-style',
		get_template_directory_uri() . '/style.css',
		array(),
		wp_get_theme( $parent )->get( 'Version' )
	);

	wp_enqueue_style(
		'child-style',
		get_stylesheet_uri(),
		array( 'parent-style' ),
		wp_get_theme()->get( 'Version' )
	);
} );

Do not use this version on a parent that already loads its stylesheet. On the test site it made Twenty Twenty-Five’s stylesheet load twice: once as style.css under parent-style, and once as style.min.css under the theme’s own handle.

Why does copying the parent’s functions.php into the child break the site?

Both files load. WordPress includes the child’s functions.php first, then the parent’s, and any function declared in both triggers a fatal cannot-redeclare error. The site goes white and the admin locks you out until you rename the file over FTP or SSH.

Copy the hooks you need, not the file. Where you genuinely want to replace a parent function, guard the declaration with if ( ! function_exists( 'parent_function_name' ) ). The child loads first, so your version wins and the parent’s copy is skipped. That trick only works for functions the parent declares conditionally; anything declared unconditionally in the parent will still collide.

The load order has a second consequence: at file scope in the child, the parent’s functions are not defined yet. Calling one directly from functions.php throws a call-to-undefined-function error. Hook into after_setup_theme or init and call it from there.

If you have already broken the site, the recovery steps are the same as any WordPress critical error after an update: rename the child’s functions.php through your host’s file manager, load the admin, then fix the syntax.

How do you create the folder without FTP?

WP-CLI ships with a scaffold command that writes the folder, a style.css with the header and a functions.php in one go:

cd /var/www/html/wp-content/themes

wp scaffold child-theme twentytwentyfive-child \
  --parent_theme=twentytwentyfive \
  --theme_name="Twenty Twenty-Five Child" \
  --activate

Whatever you pass as --parent_theme goes into Template unchanged, so pass the parent’s folder name, not its display name. The generated functions.php already enqueues the parent stylesheet and then the child’s. It writes the version as a fixed '0.1.0' string, so swap that for wp_get_theme()->get( 'Version' ) if you want the header to drive cache busting. There is no screenshot in the output; add your own.

No WP-CLI? Run mkdir wp-content/themes/twentytwentyfive-child and create the two files by hand. Over SSH that is a nano session; the SSH commands cheat sheet for WordPress developers covers the file operations if you need them.

How do you activate it without losing customisations?

Appearance → Themes → Activate. The switch itself is instant and reversible, but three things do not follow you across:

  • Theme mods. The logo, Customizer colours, header image and any Additional CSS are stored per theme in the theme_mods_<stylesheet> option. The child starts with an empty set. The parent’s values are still in the database, just unused, so switching back restores them.
  • Menu locations. Which menu sits in which location is also a theme mod. WordPress tries to carry the assignments over when you switch, and a child normally has the same locations as its parent, so they usually survive. Check Appearance → Menus after the switch anyway.
  • Site Editor templates. In a block theme, customised templates and template parts are saved against the theme that was active when you saved them. Open the Site Editor after switching and confirm your edits still apply; re-save anything that reverted.

Widgets in a classic theme usually survive, because they live in the shared sidebars_widgets option keyed by sidebar ID, and the child registers the same IDs through the parent’s functions.php.

Two rules make the switch boring. Keep the parent theme installed, because deleting it takes the child down with it. And do the switch on a staging copy or after a database export, since re-creating a logo and a colour palette from memory is a waste of an afternoon.

Appearance → Themes lists the child theme and shows it as the active one (test site: WordPress 7.1.3, PHP 8.2)
Appearance → Themes lists the child theme and shows it as the active one (test site: WordPress 7.1.3, PHP 8.2)

How do you confirm the child is active and the styles load in order?

From the command line:

# Which theme is active, and what is its parent?
wp eval 'echo get_stylesheet() . " -> " . get_template() . "\n";'

# In what order will the two stylesheets be printed?
wp eval 'do_action("wp_enqueue_scripts"); $s = wp_styles(); $s->all_deps( $s->queue ); echo implode( "\n", array_intersect( $s->to_do, array( "twentytwentyfive-style", "child-style" ) ) ) . "\n";'

The second command should print the parent’s handle above child-style. Swap in your own parent’s handle if it is not Twenty Twenty-Five. Then load the front end and view the source. Search for twentytwentyfive-style-css and child-style-css: the parent’s tag comes first, the child’s second, with the child’s URL carrying your version string.

The active stylesheet is the child theme; its template is the parent (test site: WordPress 7.1.3, PHP 8.2):

twentytwentyfive-child -> twentytwentyfive

If the child’s link is missing, the wp_enqueue_scripts callback never ran. Usually that is a PHP error swallowed by a security plugin, or the file is named function.php. If the order is wrong, the dependency array is missing or misspelled.

For a quick check from outside, for example after deploying to a client’s site, the free WordPress theme detector on Zubaer Tools reads the homepage and the active theme’s style.css. With the child active it reports your child theme by its Theme Name and names the parent from the Template line. It does not check the stylesheet order; the source view above does that.

Does a child theme work with block themes and theme.json?

Yes, and the mechanics differ enough to be worth knowing. A block theme’s style.css holds the header and little else; most of the styling comes from theme.json and the block styles WordPress generates. Twenty Twenty-Five keeps a handful of rules there and loads the file itself, which is why the child above only adds its own stylesheet.

theme.json in the child is merged over the parent’s, key by key. You do not copy the parent’s file and edit it. You write only the parts you want to change:

{
  "$schema": "https://schemas.wp.org/trunk/theme.json",
  "version": 3,
  "settings": {
    "layout": {
      "contentSize": "720px"
    }
  }
}

On the test site that file changed the content width from the parent’s 645px to 720px and left everything else alone: the wide width stayed at 1340px and all eight palette colours were still there.

Lists are the exception to key-by-key merging. A palette, font size list or font family list in the child replaces the parent’s list as a whole. A child that declared three palette colours ended up with exactly three on the test site, and the parent’s accent-1 to accent-6 were gone, along with every pattern colour that pointed at them. If you change one colour, copy the parent’s whole palette into the child and edit it there.

Templates and template parts work the same way. Drop templates/page.html into the child and it overrides the parent’s version; leave it out and the parent’s is used. The same applies to parts/header.html.

My tip · Md. Zubaer Ahammed

Twenty Twenty-Five passes the active theme's version to its own stylesheet. On the test site the parent's style.min.css was served with the child's ?ver=1.0.0, so bumping the child's Version header refreshes both files in one go.

What else belongs in the child theme folder?

Keep the root tidy as the theme grows:

  • screenshot.png at 1200×900 so the theme card is not a grey box.
  • inc/ for split files, pulled in with require get_stylesheet_directory() . '/inc/setup.php';. get_stylesheet_directory() always points at the child; get_template_directory() points at the parent.
  • assets/ for images and extra CSS, enqueued with get_stylesheet_directory_uri().
  • patterns/ for block patterns, which the child registers automatically. The custom Gutenberg block patterns walkthrough covers the file format.

Template overrides go at the same relative path as in the parent. Copy single.php from parent to child, edit the copy, and the parent stays untouched for the next update.

Once the child is active, the next job worth doing is emptying the Customizer’s Additional CSS box into the child’s style.css and bumping the Version header on each deploy. That moves your overrides out of a database option and into a file you can diff, review and roll back with the rest of the theme.

Share this:

  • Share on X (Opens in new window) X
  • Share on Facebook (Opens in new window) Facebook
  • Share on LinkedIn (Opens in new window) LinkedIn
  • Share on WhatsApp (Opens in new window) WhatsApp
  • Share on Reddit (Opens in new window) Reddit
  • Email a link to a friend (Opens in new window) Email

Related

Advertisement
Previous Article WordPress Emails Going to Spam: Fix SPF, DKIM and DMARC

About the author

Md. Zubaer Ahammed

Md. Zubaer Ahammed

Md. Zubaer Ahammed is a senior full-stack developer with more than ten years of experience in WordPress, Laravel, Python/Django, Vue and React. Since 2018 he has worked at academy+ on learning platforms such as New Skills Academy. He also builds WordPress plugins, two of them free on WordPress.org, and chooses, reviews and publishes every tutorial on this site.

I also build WordPress plugins, including ZubFeat AI Featured Image and ZubQuant. See my plugins and services →

Related Posts

  • Laravel Rust and Go badges next to the WordPress logo with a question mark: Laravel did it, will WordPress follow? Laravel Now Runs on Rust and Go. Will WordPress Follow?
  • Create a Custom Post Type in WordPress Create a Custom Post Type in WordPress

Leave a Reply

Cancel reply

WP Tuts Hub

WordPress tutorials, themes, and plugins — written for builders.

Topics

  • WordPress & AI
  • WordPress Security
  • WordPress Development
  • WordPress Troubleshooting
  • WordPress Tips and Tricks

Resources

  • WordPress Tools
  • How WordPress Works
  • My Plugins
  • Portfolio
  • About WP Tuts Hub
  • Contact Me

© 2026 WP Tuts Hub · Md. Zubaer Ahammed

Privacy Policy Terms of Use