How to Create a Child Theme in WordPress: 6 Steps Without Breaking Your Site

If you have ever edited a theme file directly, hit “Update” on the parent theme a few weeks later, and watched your custom work vanish, you already understand why child themes exist. A child theme is a thin layer that sits on top of an existing theme and holds only your changes, so the parent can keep receiving security and compatibility updates without touching a single line of your work. This guide shows you how to create a child theme in WordPress manually, with no generator plugin involved. You will end up with a folder containing two files, a proper stylesheet header, a correct enqueue function, working template overrides, and a testing routine that keeps your live site safe. We also included the part most tutorials skip: the situations where a child theme is the wrong tool and you should build something else instead. What a Child Theme Actually Does (in 60 Seconds) WordPress loads themes in a specific order. When a child theme is active: Templates: WordPress looks for a template file in the child theme first. If it is not there, it falls back to the parent. This is how you override single.php, footer.php or a block template without copying the whole theme. functions.php: This file does not override the parent. Both files load, with the child’s functions.php loading before the parent’s. It is additive. style.css: Your child stylesheet loads after the parent’s, so your CSS wins on equal specificity. Updates: Updating the parent theme never overwrites the child folder. That is the whole concept. Two files can create a valid child theme, and one of them is optional. Before You Start: 4-Point Checklist Take a full backup (files + database) or work on a staging copy. Non negotiable. Confirm the parent theme is actively maintained. Building a child theme on an abandoned parent just postpones a bigger problem. Find the parent folder slug. Go to /wp-content/themes/ via FTP, SFTP or your host’s file manager and note the exact folder name (for example twentytwentyfive). Case sensitivity matters. Identify the theme type. Does the parent folder contain a templates/ directory and a theme.json file? Then it is a block theme. If it contains index.php, header.php, footer.php and friends, it is a classic theme. The steps differ slightly and we flag those differences below. You will also need a plain text editor (VS Code, Sublime Text, Notepad++) and file access. Word processors will corrupt your files, so avoid them. Step 1: Create the Child Theme Folder Inside /wp-content/themes/, create a new folder. The convention is the parent slug plus -child: /wp-content/themes/twentytwentyfive-child/ Rules that will save you a support ticket: No spaces, no uppercase letters, no special characters. Do not place the child folder inside the parent folder. They must be siblings. If you work with multiple client sites, use a brandable slug such as acme-child so it is obvious in backups and logs. Step 2: Create style.css With a Valid Header Create a file named style.css in your new folder. The comment block at the top is what tells WordPress this is a theme, and the Template: line is what makes it a child theme. /* Theme Name: Twenty Twenty-Five Child Theme URI: https://wptweety.org/ Description: Child theme of Twenty Twenty-Five. Holds all custom design work for this site. Author: WPTweety Author URI: https://wptweety.org/ Template: twentytwentyfive Version: 1.0.0 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 */ /* Your custom CSS starts here */ The two lines that must be perfect: Theme Name: any human readable name, must be unique on the install. Template: the exact folder name of the parent theme, not its display name. Twenty Twenty-Five will fail; twentytwentyfive works. Everything else is metadata. If you get a “broken theme, the parent theme is missing” error, 95% of the time the Template value has a typo or the parent is not installed. The team at kinsta.com reached a similar conclusion. Optional: add a screenshot Drop a screenshot.png (1200 x 900 px) in the folder so the theme looks finished in Appearance > Themes. Purely cosmetic, but nice for client handovers. Step 3: Enqueue the Stylesheets in functions.php This is where most tutorials go wrong. Create functions.php in the child folder and add the following: <?php /** * Twenty Twenty-Five Child: theme functions. */ add_action( ‘wp_enqueue_scripts’, ‘wptweety_child_enqueue_styles’, 20 ); function wptweety_child_enqueue_styles() { $parent_style = ‘parent-style’; $theme = wp_get_theme(); wp_enqueue_style( $parent_style, get_template_directory_uri() . ‘/style.css’, array(), $theme->parent()->get( ‘Version’ ) ); wp_enqueue_style( ‘child-style’, get_stylesheet_uri(), array( $parent_style ), $theme->get( ‘Version’ ) ); } Why it is written this way: Never use @import in style.css. It blocks parallel downloads and slows first paint. The array( $parent_style ) dependency guarantees your CSS loads after the parent’s, so overrides work without !important. Passing the theme version as the fourth argument gives you automatic cache busting. Bump Version: 1.0.1 in style.css and every visitor gets the fresh file. Prefix your function names (wptweety_) to avoid fatal “cannot redeclare function” errors. Important exception for block themes If the parent is a block theme, WordPress already loads both the parent and child style.css automatically. You do not need the enqueue code above, and adding it can double-load the parent CSS. For a block-theme child, a functions.php is only needed when you actually add PHP functionality. Block themes: copy theme.json selectively A child block theme can have its own theme.json. It is merged with the parent’s, not replaced, so only include the settings you are changing: { “$schema”: “https://schemas.wp.org/trunk/theme.json”, “version”: 3, “settings”: { “color”: { “palette”: [ { “slug”: “brand”, “color”: “#0b5fff”, “name”: “Brand” } ] } } } Copying the parent’s entire theme.json is a classic mistake: it freezes hundreds of values and you lose every improvement the parent ships later. Step 4: Activate and Sanity-Check Go to Appearance > Themes. Your child theme appears next to the parent. Hover it and click Live Preview first if the parent is a classic theme. For block themes, activate on staging instead.

How to Create a Child Theme in WordPress: 6 Steps Without Breaking Your Site Read More ยป