Why Use a Child Theme?
One of the biggest mistakes beginners make is editing the parent theme’s files directly. While this might seem convenient, the next update will overwrite all your changes. A child theme solves this problem. It acts like a safe layer where you can override styles, templates, and functions—without touching the parent.
With a child theme, you can:
- Preserve your customizations during updates
- Experiment with designs and layouts safely
- Add custom CSS, PHP, or even new template parts
In short, it’s the best practice for customizing WordPress themes.
Step 1: Create the Child Theme Folder
Navigate to /wp-content/themes/
and create a new folder. Name it after your parent theme with -child
added. For example:
/wp-content/themes/twentytwentyfive-child/
Step 2: Add the Style.css File
Inside your new folder, create a style.css
file. At the very top, add this:
/*
Theme Name: Twenty Twenty-Five Child
Template: twentytwentyfive
Version: 1.0.0
Description: Child theme for Twenty Twenty-Five
*/
👉 The Template must match the folder name of the parent theme, or WordPress won’t recognize it.
Step 3: Add Functions.php to Enqueue Styles
Next, create a functions.php
file. This will load your parent theme’s CSS first, then your child theme’s CSS:
<?php
add_action('wp_enqueue_scripts', function () {
$parent = 'twentytwentyfive-style';
wp_enqueue_style($parent, get_template_directory_uri() . '/style.css');
wp_enqueue_style('tw25-child-style', get_stylesheet_uri(), [$parent], '1.0.0');
});
This ensures that your child theme inherits the parent theme’s design while letting you override styles.
Step 4: (For Block Themes) Add theme.json
If you’re using a block theme, most customization is done through theme.json
. Create a file named theme.json
in your child theme folder:
{
"$schema": "https://schemas.wp.org/trunk/theme.json",
"version": 2,
"settings": {
"color": {
"palette": [
{ "slug": "brand", "color": "#F05365", "name": "Brand" }
]
}
},
"styles": {
"typography": { "fontFamily": "Poppins" }
}
}
Step 5: Activate the Child Theme
Log in to your WordPress dashboard → Appearance > Themes. You should now see your new child theme. Click Activate, and you’re ready to customize.
Common Pitfalls to Avoid
- Wrong Template name: Double-check your parent theme folder name.
- Using
@import
: Never import parent CSS; enqueue it infunctions.php
. - Copying too many files: Only override what you need.
Final Thoughts
A child theme gives you freedom and safety when customizing WordPress. Whether you’re tweaking a design, adding functionality, or experimenting with layouts, this method ensures your work won’t be lost during updates.
💡 Pro tip: If you’re making lots of customizations, consider using version control (Git) for your child theme. That way, you always have a history of your changes.