Support article
How to Create a WordPress Child Theme
Learn to create a WordPress child theme to customize design and code without losing changes when the parent theme updates.
Introduction
A child theme lets you customize a WordPress theme without directly editing its original files.
The original theme is called the parent theme. The child theme inherits its design and functionality but can add its own styles, functions, and templates, so when the parent theme updates, your changes stay separate.
Back up before you start, and if the site is in production, test the changes in a staging environment.
When a child theme makes sense
It’s the right approach when you need to add CSS you want kept as part of the theme, modify PHP templates in a classic theme, add presentation-related functions, or override templates in a block theme.
It isn’t always necessary: for a few style tweaks you can use Appearance > Customize > Additional CSS or the Site Editor tools. For functions that don’t depend on the design, a dedicated plugin is usually better.
Before you start
You’ll need access to the file manager, FTP, or SFTP, the exact folder name of the parent theme, and a text editor that saves in UTF-8. The parent theme’s folder lives inside wp-content/themes/; for example, if the path is wp-content/themes/twentytwentyfive/, the value you’ll use as Template is twentytwentyfive — exactly matching the folder name, not the display name shown in WordPress.
Step 1: create the child theme’s folder
Inside wp-content/themes, create a folder using lowercase letters, numbers, and hyphens, with no spaces or special characters, for example wp-content/themes/my-child-theme/. Only style.css is required for WordPress to recognize a child theme; functions.php is added when you need to load styles or add functions.
Step 2: create the style.css file
Add a header like this:
/*
Theme Name: My Child Theme
Theme URI: https://yourdomain.com/
Description: Child theme for site customizations.
Author: Your name or company
Template: parent-theme-folder-name
Version: 1.0.0
Text Domain: my-child-theme
*/
The essential field is Template: parent-theme-folder-name, for example Template: twentytwentyfive. Don’t write a full path or the theme’s display name — WordPress needs the exact folder name of the parent theme. You can add your own styles after the header.
Step 3: decide how to load the styles
There’s no single valid method for every theme: some load the child theme’s styles automatically; others need them enqueued from functions.php. Check the parent theme’s documentation first.
If you need to load the child’s stylesheet manually, create functions.php with:
<?php
add_action( 'wp_enqueue_scripts', 'mihosting_child_theme_styles' );
function mihosting_child_theme_styles() {
wp_enqueue_style(
'child-theme-styles',
get_stylesheet_uri(),
array(),
wp_get_theme()->get( 'Version' )
);
}
If the parent only loads its own stylesheet, you can load the parent’s style first and then the child’s:
<?php
add_action( 'wp_enqueue_scripts', 'mihosting_child_theme_styles' );
function mihosting_child_theme_styles() {
wp_enqueue_style(
'parent-theme-styles',
get_parent_theme_file_uri( 'style.css' )
);
wp_enqueue_style(
'child-theme-styles',
get_stylesheet_uri(),
array( 'parent-theme-styles' ),
wp_get_theme()->get( 'Version' )
);
}
Don’t copy this block automatically if the theme’s documentation says otherwise — loading the same stylesheet twice can duplicate styles or hurt performance.
Step 4: activate the child theme
Go to Appearance > Themes, find the child theme, and click Activate. Check the homepage, posts, pages, forms, and other important sections. The parent theme needs to stay installed (it doesn’t need to be active), since WordPress needs its files for the child theme to work.
How to modify templates in a classic theme
To override a template, find the file in the parent theme, copy it to the child theme keeping the same relative path (for example parent-theme/single.php to child-theme/single.php), and modify only the child theme’s copy. Don’t copy files you don’t need to change — each copied template stops automatically receiving the parent theme’s updates, and you’ll need to review it after future updates.
How to customize a block theme
Block themes can use theme.json, HTML templates in templates/, template parts in parts/, and patterns in patterns/. A child theme can override templates and parts by placing files with the same name and path (for example child-theme/templates/single.html), and can also include its own theme.json.
Keep in mind that some changes made from the Site Editor are saved in the database and can take priority over the files. If a template isn’t reflecting your changes, check whether a saved customization exists and use the reset option when needed.
How to use functions.php correctly
The child theme’s functions.php does not replace the parent’s — WordPress loads both. You can add your own functions:
<?php
add_action( 'after_setup_theme', 'mihosting_child_theme_setup' );
function mihosting_child_theme_setup() {
add_theme_support( 'custom-logo' );
}
Avoid copying the entire parent theme’s functions.php — it can cause duplicate functions and fatal errors (see WordPress 500 error and white screen). Use unique prefixes for your functions, classes, and constants, and avoid generic names.
To keep the code organized, you can create extra files (for example my-child-theme/inc/customizations.php) and load them with require_once get_theme_file_path( 'inc/customizations.php' );, which respects the child theme’s hierarchy.
Best practices
Make changes in a testing environment, document which files you’ve overridden and why, keep the parent theme updated, review copied templates after each major update, validate your PHP code before uploading it, and keep functions that should stay active regardless of the theme in a plugin instead.
Common issues
The child theme shows as broken
Check that style.css exists and that Template matches the parent’s folder exactly. Also confirm the parent theme is installed.
The site loses its styles when the child theme is activated
The child theme isn’t loading the right stylesheet. Check the parent theme’s documentation and the wp_enqueue_style() code.
My CSS changes aren’t showing
Clear the plugin, server, CDN, and browser caches. Also check the priority and specificity of the CSS rules.
A fatal error appears when activating the theme
Check functions.php — there may be a syntax error or a function with the same name as one in the parent theme or a plugin.
The copied template isn’t being used
Confirm the name, path, and template hierarchy. On block themes, also check whether a customized version is saved in the database.
Frequently asked questions
Can I create a child theme of another child theme?
WordPress officially only supports two levels: parent theme and child theme.
Do I lose settings when activating the child theme?
Some settings can depend on the theme’s identifier and may need to be set up again. Back up and test first.
Do I need to copy every file from the parent theme?
No. Only copy the files you’re going to modify.
Does a child theme improve security?
Not on its own. Its advantage is keeping customizations separate and making updates easier.
Conclusion
A child theme is the right way to keep theme-dependent customizations without editing the original files. Create a folder, add a valid header in style.css, load the styles according to how the parent theme works, and copy only the templates you need. If the change doesn’t depend on the design, consider putting it in a plugin so it keeps working if you switch themes.