A WordPress child theme is a separate theme that inherits all the styling and functionality of a parent theme, letting you make changes without altering the parent’s files. You create one by making a folder with a style.css and functions.php file, then activate it from your dashboard. This approach keeps your customizations safe when the parent theme updates, which is the main reason developers and site owners use it.
Why Use a Child Theme?
The main reason is updates. When a parent theme releases a new version, WordPress overwrites the theme files. If you have edited the parent theme directly, your changes vanish. A child theme stores your modifications in separate files, so updating the parent does not touch them. This is especially important for popular themes like Astra, GeneratePress, or Storefront, which update frequently.
Another benefit is that a child theme gives you a safe place to add custom PHP functions, CSS tweaks, and template overrides. You can experiment without breaking your live site, because deactivating the child theme reverts to the parent. It also makes your site more portable – you can move the child theme to another site and keep the same customizations.
Many hosting companies and theme developers recommend child themes for any site that is not a simple blog. Even if you only add a few lines of CSS, a child theme is the correct way to do it.
How a Child Theme Works
A child theme is a minimal theme that declares its parent. WordPress looks for two files in the child theme folder:
- style.css – the file that contains the theme header comment, including the
Templateline that names the parent theme folder. - functions.php – the file that loads the parent’s styles and lets you add your own PHP functions.
When you activate the child theme, WordPress loads the parent theme for all templates and functions, then applies the child’s overrides. The child theme does not need to copy every template file – only the ones you want to change. For example, if you want to alter the footer, you copy footer.php from the parent into the child folder and edit it there.
The functions.php file in a child theme works differently from the parent’s. It is loaded before the parent’s functions file, so you can unhook parent functions or replace them. A common practice is to enqueue the parent style and then your own custom style:
add_action( 'wp_enqueue_scripts', 'my_child_enqueue_styles' );
function my_child_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
}
This ensures the parent’s CSS loads first, and then any additional CSS you add in the child takes precedence.
How to Create a Child Theme (Step by Step)
You can create a child theme manually or with a plugin. Here is the manual method, which works on any WordPress site:
- Create a new folder in
/wp-content/themes/– name it something likemytheme-child. - Inside that folder, create a
style.cssfile with the following header:
/* Theme Name: My Theme Child Template: mytheme */
The Template line must exactly match the parent theme’s folder name. For example, if the parent folder is twentytwentyfour, you write Template: twentytwentyfour.
- Create a
functions.phpfile with the enqueue code shown above. - Go to Appearance > Themes in your WordPress admin. You will see your child theme listed. Activate it.
That is the whole process. You can now add custom CSS in the child’s style.css or via the Customizer, and add PHP functions in the child’s functions.php.
If you prefer a plugin, options like “Child Theme Configurator” guide you through the process with a few clicks. They handle the folder creation and file setup automatically.
Choosing Between a Child Theme and a Page Builder
Some site owners skip child themes and use a page builder (like Elementor or Beaver Builder) to make changes. Page builders store their modifications in the database, not in theme files, so updates do not wipe them out. This works well for layout changes, but it does not help with PHP functions or template overrides. If you need to add custom code, a child theme is still the right tool.
Another alternative is a “custom CSS” plugin that injects styles without touching theme files. That is fine for small tweaks, but it does not allow you to modify template files or add functions. For anything beyond simple CSS, a child theme is the recommended approach.
If you are using a block theme (like Twenty Twenty-Four), the situation is slightly different. Block themes use theme.json for global styles, and you can add custom CSS in the site editor. You can still use a child theme for block themes, but many changes can be made through the editor without one. However, if you want to override template parts or add PHP, a child theme remains useful.
Common Problems and How to Fix Them
The most frequent issue is a white screen after activating a child theme. This usually happens because the Template line in style.css is wrong – the folder name is case-sensitive or has a typo. Check that the folder name matches exactly.
Another problem is styles not loading. This occurs when the child theme’s functions.php does not enqueue the parent style. Without that enqueue, the child theme has no CSS at all. Add the enqueue code and clear any caching plugins.
If your custom CSS does not override the parent, the issue is specificity. Parent styles may use more specific selectors or !important. You can increase your selector specificity or add !important to your rules, but use it sparingly.
Finally, if you see a “broken theme” error, it means the parent theme is not installed or is deactivated. Install the parent theme and keep it active (the child theme will use it even if the parent is not activated, but it must be present).
Safety and Best Practices
Always back up your site before creating or modifying a child theme. A simple mistake can break your layout, and a backup lets you restore quickly. Also, test the child theme on a staging site if you have one.
Do not edit the parent theme directly – that defeats the purpose. Keep all changes in the child theme. When the parent updates, your child theme remains untouched.
Use a child theme for any custom code, but do not overload it with hundreds of functions. Keep your code organized and commented. If you are not comfortable with PHP, stick to CSS changes via the Customizer or a plugin.
One common misconception is that a child theme slows down your site. In practice, the performance impact is negligible – WordPress loads one extra stylesheet and a small PHP file. The benefits of safe updates far outweigh any tiny overhead.
Frequently Asked Questions
Do I need a child theme if I use a page builder?
No, not for layout changes. Page builders store their data in the database, so updates do not affect them. But if you add custom PHP or edit template files, a child theme is still necessary.
Can I create a child theme for any WordPress theme?
Yes, as long as the parent theme is installed on your site. The child theme just needs the correct Template name in its style.css.
Will a child theme break when the parent theme updates?
No, that is the point. The child theme only contains your changes, so updates to the parent do not overwrite them. However, if the parent changes its template structure, your overrides may need adjustment.
What is the difference between a child theme and a custom theme?
A child theme inherits everything from a parent theme, so you only write the parts you want to change. A custom theme is built from scratch, giving you full control but requiring much more work.
Can I use a child theme with a block theme?
Yes, you can. Block themes support child themes, though many changes can be made through the site editor. Use a child theme if you need to override template parts or add PHP functions.
How do I update a child theme?
You do not update a child theme – you update the parent theme. The child theme stays as is. If you want to change your customizations, you edit the child theme files directly.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Tongue Escape Codes: What They Are0.20 movements/s
- Claude Code Workflow Habits Worth Trying
- HDMI 2.1 Explained: Why It Matters for Gaming
- Veeam Plugin for VMware Cloud Director: How It Works
- Best Path of Titans Server Hosting: Top Picks
- Oppo First Foldable: 120Hz Display & Snapdragon 888