A WordPress theme controls how your site looks and often how parts of it behave. When you tweak a theme directly and then update it later, your changes usually vanish — overwritten by the new version.
A child theme fixes this. It lets you customize the look and behavior of your site while keeping the original parent theme intact and updatable.
In this guide, you will learn what a WordPress child theme is, when you should use one, and the exact steps to create a child theme in WordPress using folders, style.css, and functions.php. By the end, you will know how to keep your customizations safe during theme updates.
What is a WordPress child theme?
A WordPress child theme is a theme that inherits design and functionality from another theme, called the parent theme. The parent theme provides the base styles and templates, while the child theme contains only your custom changes.
When WordPress loads your site, it uses the child theme first. If a file is missing in the child theme, WordPress falls back to the parent theme’s version.
Key points of a child theme in WordPress:
- The parent theme does most of the heavy lifting (layouts, templates, features).
- The WordPress child theme contains only the files you want to modify or add.
- Updating the parent theme does not touch your child theme files.
- You can safely experiment with CSS and templates without breaking the original theme.
Understanding this parent–child relationship makes it much easier to confidently create a child theme in WordPress.
When should you use a child theme in WordPress?
You do not need a child theme for every site. The more you customize, the more a WordPress child theme makes sense.
Use a WordPress child theme when:
- You plan to change theme files (PHP templates, functions.php).
- You want to maintain a lot of custom CSS beyond small tweaks.
- You expect regular parent theme updates.
- You are building custom layouts or functionality on top of an existing theme framework.
If you only need a couple of small CSS tweaks, the Additional CSS box in the Customizer or a site-specific plugin might be enough and you may not need to create a child theme in WordPress at all.
Child theme vs editing the parent theme
| Approach | Pros | Cons |
|---|---|---|
| Edit parent theme directly | Fast for a one-off change. | Updates overwrite your changes, risky and hard to maintain. |
| Use Additional CSS only | Safe for small visual tweaks, no files to manage. | Cannot change templates or PHP; CSS can get messy over time. |
| Create a WordPress child theme | Safe updates, full control over CSS, templates, and functions. | Requires a bit of initial setup and basic file access. |
Managed well, a child theme gives you long-term flexibility without losing changes on update day.
Step 1: Prepare to create your WordPress child theme
Before you create a child theme in WordPress, make a few quick preparations so the process is smooth and low risk.
- Identify the parent theme: Note the exact folder name in
wp-content/themes(for example,astra,blocksy, ortwentytwentyfour). - Get file access: Use an FTP client, SFTP, or your host’s file manager to access
wp-content/themes. - Take a backup: Create a fresh backup of your site so you can roll back if something goes wrong while you create your child theme.
- Gather basic info: Theme name, author, and version; you will use them in the child theme header.
Step 2: Create the child theme folder and style.css file
To create a child theme in WordPress, you need a new folder and a style.css file with a required header comment.
Create the child theme folder
- Go to
wp-content/themes. - Create a new folder for your child theme. A common pattern is
parenttheme-child, for example:astra-childblocksy-childtwentytwentyfour-child
Create style.css for your child theme
Inside the new folder, create a file named style.css and add a header like this:
/*
Theme Name: Astra Child
Theme URI: https://example.com/astra-child
Description: Child theme for the Astra theme
Author: Your Name
Author URI: https://example.com
Template: astra
Version: 1.0.0
*/
/* Add your custom CSS below this line */
Important:
- Template must match the folder name of the parent theme exactly (case-sensitive).
- Theme Name can be whatever you like; it appears in the WordPress dashboard for your new child theme.
Step 3: Enqueue parent and child theme styles correctly
In older tutorials about how to create a child theme in WordPress you might see @import used inside style.css. That method is now discouraged because it slows things down.
The modern way in a WordPress child theme is to enqueue the parent and child styles in functions.php.
Create functions.php in your child theme
In your child theme folder, create a file named functions.php and add code similar to this:
/**
* Enqueue parent and child theme styles.
*/
function astra_child_enqueue_styles() {
$parent_style = 'astra-style'; // This is the parent theme handle.
wp_enqueue_style(
$parent_style,
get_template_directory_uri() . '/style.css'
);
wp_enqueue_style(
'astra-child-style',
get_stylesheet_directory_uri() . '/style.css',
array( $parent_style ),
wp_get_theme()->get( 'Version' )
);
}
add_action( 'wp_enqueue_scripts', 'astra_child_enqueue_styles' );
Adjust the function name and $parent_style handle according to your theme. Many theme authors document the correct handle in their developer docs or in the parent theme’s code, which is helpful when you create a child theme in WordPress based on their product.
Step 4: Activate your new WordPress child theme
Once the folder, style.css and functions.php are in place, you can activate the child theme from your WordPress dashboard.
- Log in to your WordPress dashboard.
- Go to Appearance » Themes.
- Find your new child theme in the list (for example, Astra Child).
- Click Activate.
Your site should look the same as before. That is expected — the WordPress child theme is inheriting everything from the parent theme until you start adding customizations.
If the layout looks broken or styles are missing, double-check:
- The
Templatevalue in style.css matches the parent folder name. - The
wp_enqueue_style()paths and handles are correct.
Step 5: Override templates in your WordPress child theme
One of the biggest advantages when you create a child theme in WordPress is the ability to override template files without touching the parent theme.
To override a template:
- In the parent theme folder, find the template you want to modify (for example,
single.php,page.php, orheader.php). - Copy that file into your child theme folder, keeping the same relative path and file name.
- Edit the copied file inside your child theme.
WordPress will now use the child theme’s version of the template instead of the parent’s.
Examples:
- Copy
single.phpto customize single blog post layouts. - Copy
page.phpto change how static pages display. - Copy
footer.phpto add custom footer elements or tracking codes.
Be careful not to remove essential template tags like the_content() unless you know what you are doing with your WordPress child theme.
Step 6: Add custom CSS and functions to your child theme
With the base child theme in place, you can start adding the changes you actually wanted. This is the “fun” part of learning how to create a child theme in WordPress.
Adding custom CSS
Add your CSS underneath the header comment in style.css:
/* Change primary button color */
button,
.button,
a.button-primary {
background-color: #0057ff;
border-radius: 999px;
}
Because your child theme stylesheet is loaded after the parent’s, your rules can override many of the parent rules without using !important everywhere.
Adding custom PHP functions
You can also add your own functions and hooks to functions.php:
// Example: add a custom message after the content on blog posts.
function my_childtheme_after_content( $content ) {
if ( is_singular( 'post' ) && is_main_query() ) {
$content .= '<p class="after-post-note">Thanks for reading!</p>';
}
return $content;
}
add_filter( 'the_content', 'my_childtheme_after_content' );
Always test new functions on a staging site or low-traffic time first in case you introduce errors into your WordPress child theme.
Best practices for maintaining a WordPress child theme
A child theme gives you power and flexibility, but it also becomes part of your site’s long-term codebase. A few habits will keep things tidy after you create a child theme in WordPress.
- Comment your changes: Add comments in CSS and PHP explaining why you changed something and when.
- Group related tweaks: Keep typography, layout, and component styles in sections to avoid a huge, random CSS file.
- Use a staging site: Test major template changes on staging before pushing them live.
- Track customizations: Keep a simple changelog file or document listing important updates to your child theme.
- Update the parent theme regularly: Your WordPress child theme exists so you can safely stay current with parent theme updates.
Troubleshooting common child theme issues
If something breaks after you create a child theme in WordPress, start with these checks before you panic.
- Styles disappeared: Confirm the
Templatename in style.css is correct and yourfunctions.phpenqueues the parent stylesheet. - White screen or fatal error: There may be a syntax error in functions.php. Temporarily rename the child theme folder via FTP to revert to the parent.
- Template changes not showing: Make sure the file path inside the child theme exactly matches the parent theme’s path and that caching is cleared.
- Header comment mistake: If style.css is missing or the header is malformed, WordPress may not recognize your child theme at all.
These checks solve most problems people run into when they first learn how to create a child theme in WordPress.




