Learning how to create a child theme in WordPress is one of the most important skills any WordPress site owner or developer can acquire. A child theme lets you safely customize your site's appearance and functionality without touching the parent theme's core files — meaning your changes survive every theme update. In this guide, you will learn exactly what a child theme is, why you need one, and how to build one from scratch using two proven methods.
What Is a WordPress Child Theme and Why Do You Need One?
A child theme is a theme that inherits the design, templates, and functionality of another theme — called the parent theme. Any changes you make inside the child theme override the corresponding files in the parent theme, while everything else continues to load from the parent automatically.
Without a child theme, any direct edits you make to a theme's PHP, CSS, or JavaScript files will be wiped out the moment the theme author releases an update. This is a painfully common mistake that costs site owners hours of rework.
Key Benefits of Using a Child Theme
- Update-safe customizations: Parent theme updates never overwrite your work.
- Easy rollback: You can deactivate the child theme at any time to revert to the original parent design.
- Cleaner development workflow: Your custom code stays isolated and organized.
- No risk to core theme files: The parent theme stays pristine for debugging purposes.
- Inheritance of all parent features: You only need to create files for the parts you actually want to change.
What You Need Before You Start
Before creating a child theme, make sure you have the following in place. The process is straightforward, but skipping these prerequisites is the number one cause of errors for beginners.
Prerequisites Checklist
- A working WordPress installation (local or live server)
- A parent theme already installed and active (e.g., Twenty Twenty-Four, Astra, or any other theme)
- Access to your server via FTP client (such as FileZilla), cPanel File Manager, or WP-CLI
- A plain-text code editor (VS Code, Notepad++, or Sublime Text)
- Basic familiarity with uploading files to your server
Method 1: Create a Child Theme Manually (Recommended for Developers)
The manual method gives you full control and helps you understand exactly what a child theme is made of. You only need to create two files to get started: a style.css file and a functions.php file.
Step 1 — Create the Child Theme Folder
- Open your FTP client or cPanel File Manager and navigate to
wp-content/themes/. - Create a new folder inside the
themesdirectory. Name it something descriptive and lowercase with hyphens, such astwentytwentyfour-child. Use your actual parent theme's folder name as the base to keep things organized. - Note the exact folder name of your parent theme — you will need it in the next step. You can find it inside
wp-content/themes/(for example,twentytwentyfour).
Step 2 — Create the style.css File
- Inside your new child theme folder, create a new file called
style.css. - Open it in your text editor and add the following header comment. This comment is mandatory — WordPress reads it to recognize and register your theme.
/*
Theme Name: Twenty Twenty-Four Child
Theme URI: https://yourwebsite.com
Description: A child theme for Twenty Twenty-Four
Author: Your Name
Author URI: https://yourwebsite.com
Template: twentytwentyfour
Version: 1.0.0
License: GNU General Public License v2 or later
Text Domain: twentytwentyfour-child
*/
The most critical line here is Template:. This must match the exact folder name of the parent theme inside wp-content/themes/. If this value is wrong, your child theme will fail to activate. Everything else in the header can be customized freely.
Step 3 — Create the functions.php File
- Inside the same child theme folder, create a new file called
functions.php. - Add the following PHP code to correctly enqueue the parent theme's stylesheet. This ensures the parent styles load before your child theme styles, so your overrides work as expected.
<?php
add_action( 'wp_enqueue_scripts', 'my_child_theme_enqueue_styles' );
function my_child_theme_enqueue_styles() {
wp_enqueue_style(
'parent-style',
get_template_directory_uri() . '/style.css'
);
wp_enqueue_style(
'child-style',
get_stylesheet_directory_uri() . '/style.css',
array( 'parent-style' )
);
}
Important note for block themes: If your parent theme is a modern FSE (Full Site Editing) block theme like Twenty Twenty-Four, it may not use a style.css file for its main styles. In that case, you may only need the style.css header file and an empty or minimal functions.php. The enqueue function above is primarily relevant for classic (non-block) themes.
Step 4 — Upload and Activate the Child Theme
- If you created the files locally, upload the entire child theme folder to
wp-content/themes/via FTP or cPanel. - Log into your WordPress admin dashboard.
- Go to Appearance > Themes.
- You should now see your child theme listed. Click Activate.
- Visit your website's front end to confirm it looks identical to before — this means the child theme is inheriting everything correctly from the parent.
Method 2: Create a Child Theme Using WP-CLI
If you have WP-CLI installed on your server or local environment, you can scaffold a child theme in seconds. This is the fastest approach for developers who work in the command line.
Using the WP-CLI Scaffold Command
- Open your terminal and navigate to your WordPress installation root directory.
- Run the following command, replacing the values with your own theme details:
wp scaffold child-theme twentytwentyfour-child \
--parent_theme=twentytwentyfour \
--theme_name="Twenty Twenty-Four Child" \
--author="Your Name" \
--author_uri="https://yourwebsite.com" \
--theme_uri="https://yourwebsite.com" \
--activate
The --activate flag tells WP-CLI to activate the child theme immediately after creation. This single command generates the correct folder structure, style.css with the proper header, and a functions.php with the enqueue function — all done for you automatically.
Customizing Your Child Theme
Once your child theme is active, you are ready to start making customizations. Here is how to handle the most common scenarios.
Adding Custom CSS Styles
Open your child theme's style.css file and add your custom CSS rules below the header comment block. These styles will be loaded after the parent styles and will override them where there is a conflict.
/* Custom styles for the child theme */
body {
font-family: 'Georgia', serif;
background-color: #f9f9f9;
}
a {
color: #0073aa;
}
a:hover {
color: #005177;
text-decoration: underline;
}
Overriding a Parent Theme Template File
- Identify the template file you want to modify inside the parent theme folder (for example,
header.php,footer.php, orsingle.php). - Copy that file from the parent theme folder.
- Paste the copied file into your child theme folder, maintaining the same file name and relative path.
- Edit the copied file in your child theme. WordPress will automatically use the child theme version instead of the parent's version.
Never edit the parent theme's files directly. Always copy them into the child theme first.
Adding Custom PHP Functions
You can add custom PHP functions, hooks, and filters directly inside your child theme's functions.php. These functions will be loaded in addition to — not instead of — the parent theme's functions.php functions.
<?php
// Example: Add a custom body class
function my_custom_body_class( $classes ) {
$classes[] = 'my-custom-class';
return $classes;
}
add_filter( 'body_class', 'my_custom_body_class' );
Common Mistakes to Avoid
Even experienced developers make simple errors when creating child themes. Keep this checklist in mind to avoid the most frequent pitfalls.
Mistakes That Break Child Themes
- Wrong Template value in style.css: The
Template:header must exactly match the parent theme's folder name — case-sensitive. - Using @import instead of wp_enqueue_style: Using
@import url("../parenttheme/style.css");in CSS causes performance issues and loading order problems. Always use the PHP enqueue method. - Forgetting the opening PHP tag: Your
functions.phpmust start with<?php— missing it causes a white screen of death. - Editing the parent theme directly: This defeats the entire purpose of using a child theme.
- Deleting the parent theme: The parent theme must remain installed for the child theme to function. Never delete it.
- Uploading incomplete files: Always verify that both
style.cssandfunctions.phpwere uploaded successfully before activating.
Frequently Asked Questions
Will creating a child theme slow down my WordPress website?
No. A properly configured child theme adds negligible overhead to your site. The child theme simply loads the parent theme's assets and then applies your customizations on top. In fact, using a child theme correctly — by enqueuing stylesheets properly — can actually be slightly more performant than the old @import method.
Can I create a child theme for any WordPress theme?
Yes, you can create a child theme for virtually any WordPress theme, whether it is a free theme from the WordPress.org repository or a premium theme from a marketplace. The process is the same. Just make sure the parent theme remains installed and that the Template: value in your child theme's style.css exactly matches the parent theme's folder name.
Do I need a child theme if I only use the WordPress Customizer or block editor?
Changes made through the WordPress Customizer or the block-based site editor are stored in the database, not in theme files, so they are generally safe from theme updates. However, if you want to make any direct file changes — editing PHP templates, adding custom CSS outside the Customizer, or writing custom functions — you absolutely need a child theme to protect those changes.
What happens to my child theme if I update the parent theme?
Nothing bad happens to your child theme's files when the parent theme updates. Your custom style.css, functions.php, and any overridden template files remain untouched in the child theme folder. The parent theme updates its own files independently. This is precisely why using a child theme is the recommended approach for all WordPress customization.
Creating a child theme in WordPress is a foundational skill that protects your work and keeps your site maintainable for the long term. Whether you prefer the manual method or the WP-CLI approach, the process takes only a few minutes and saves you from countless hours of lost customization work. If you want an even faster way to handle tasks like this, WP AI Agent is a powerful tool that lets you manage, configure, and customize your WordPress site through simple natural-language AI chat — no coding or FTP required.