preloader

How to Create a WordPress Child Theme

A child theme is a WordPress theme that inherits all the styles and functionality of a parent theme but keeps your customisations in separate files. When the parent theme updates, your customisations survive because they live in the child theme files, not in the parent. If you ever add custom CSS or edit theme files directly and worry about updates overwriting your changes, a child theme solves that problem permanently.

Why You Need a Child Theme

When you customise a WordPress theme by editing its files directly (style.css, functions.php, template files), those changes are overwritten the next time the theme updates. Theme updates are important – they fix security vulnerabilities and bugs. Skipping updates to preserve customisations is a security risk. A child theme lets you update the parent theme freely while keeping every customisation intact.

The Customizer’s Additional CSS field is the exception – that CSS is stored in the database, not in theme files, and survives updates. For small CSS tweaks, the Customizer is fine. For larger customisations, custom PHP functions, or template overrides, a child theme is the correct approach.

Method 1: Create Manually (Two Files)

A minimal child theme needs exactly two files in a new folder inside /wp-content/themes/.

Create a folder named your-theme-child (replace “your-theme” with your actual theme folder name). Inside it, create two files:

style.css:

/*
 Theme Name:   My Theme Child
 Theme URI:    https://yoursite.com
 Description:  Child theme for My Theme
 Author:       Your Name
 Template:     parent-theme-folder-name
 Version:      1.0.0
*/

/* Add your custom CSS below this line */

The Template line must match the exact folder name of your parent theme in /wp-content/themes/. Get the folder name right – if the parent theme folder is called “twentytwentythree”, the Template line must say “twentytwentythree” exactly.

functions.php:

<?php
add_action( 'wp_enqueue_scripts', 'child_theme_enqueue_styles' );
function child_theme_enqueue_styles() {
    wp_enqueue_style(
        'parent-style',
        get_template_directory_uri() . '/style.css'
    );
}

This functions.php loads the parent theme’s stylesheet. Without it, the child theme would not load the parent’s CSS and your site would look unstyled.

Need help optimising your WordPress site? Describe your project and get a free estimate.

Method 2: Use a Plugin (No Code)

The “Child Theme Configurator” plugin generates a child theme automatically alongside tools like WP Rocket for caching. Install it, go to Tools -> Child Themes, select your parent theme, and click Analyse then Create Child Theme. The plugin creates the correct folder structure and both required files, then activates the child theme. Use this method if you are not comfortable creating files manually or connecting to your server via FTP.

Activating the Child Theme

Go to Appearance -> Themes. Your child theme appears as a separate theme entry. Click Activate. Your site now runs on the child theme – all parent theme styles and functionality are inherited automatically. Verify the site looks correct after activation. If something breaks, the parent theme can be reactivated immediately while you troubleshoot.

What to Put in the Child Theme

Custom CSS – add to the child theme’s style.css after the header comment. This CSS overrides parent theme styles.

Custom PHP functions – add to the child theme’s functions.php. Hook into WordPress actions and filters, add shortcodes, register custom post types.

Template overrides – copy a template file from the parent theme to the same path in the child theme folder. WordPress automatically uses the child theme version. Example: copy /parent-theme/page.php to /child-theme/page.php and edit the child version. The parent’s page.php is untouched and updated normally.

Checking the Child Theme Is Working

Add a distinctive CSS rule to your child theme’s style.css:

/* Test rule - delete after confirming */
body {
    outline: 3px solid red;
}

If a red outline appears on your site after clearing cache, the child theme CSS is loading. Delete the test rule. If nothing appears, check the Template name in the child theme’s style.css header matches the parent theme folder name exactly.

Common Child Theme Mistakes

The most frequent child theme problem: the Template name in style.css does not match the parent theme’s folder name exactly. WordPress folder names are case-sensitive on Linux servers. If the parent theme folder is “Avada” (capital A), the Template line must say “Avada” not “avada”. Get the folder name from your FTP client or the Themes directory in File Manager – do not guess or use the theme’s display name.

The second common mistake: adding @import to load the parent stylesheet in style.css instead of using the functions.php enqueue method. The @import approach works but is slower than the wp_enqueue_style approach because @import blocks CSS loading. Always use the functions.php method shown above.

The third mistake: overriding entire template files when only a small section needs changing. If you only need to change the footer widget area, do not copy the entire footer.php – look for a more specific template part. The more template files you override, the more work is needed when the parent theme updates those templates.

Keep Reading

Previous Post How to Set Up Cloudflare with WordPress Next Post How to Set Up WordPress Multisite

Need Help With Your WordPress Site?

If you need help with WordPress fixes, plugin issues, theme customization, or development work, feel free to get in touch.

Get a Free Estimate