How to Create a WordPress Child Theme (Step-by-Step Guide)
Creating a WordPress child theme is the best way to customise your website while keeping the parent theme’s updates and functionality intact. Whether you’re tweaking styles, adding new features, or modifying templates, a child theme gives you full control without risking your changes being overwritten.
What is a WordPress Child Theme?
A child theme is a sub-theme that inherits all the functionality, styling, and features of another theme, called the parent theme. The main advantage of using a child theme is that it allows you to modify your site without affecting the original theme’s code. This means you can safely update the parent theme without losing your customisations.
Think of it this way: A child theme is like adding a body kit to your car. The car is your parent theme – it works perfectly as it is. The body kit (child theme) lets you make it unique without changing the car’s core functionality.
When Should You Use a Child Theme?
If you’re making any modifications to a theme, a child theme is the way to go. Here’s when you should definitely use one:
- Customising CSS styles without using additional plugins.
- Modifying template files (e.g., single.php, header.php).
- Adding new functionality via
functions.php
. - Overriding parent theme settings safely.
- Avoiding theme updates erasing your changes.
If you’re just making small CSS changes, you might be fine using the WordPress Customizer or Additional CSS option, but for anything beyond that, a child theme is the best approach.
How to Make a WordPress Child Theme (Step by Step)
Creating a child theme is easy. Follow these steps to set it up:
Step 1: Create a Child Theme Folder
- Access your site’s files via FTP or File Manager.
- Navigate to
wp-content/themes
. - Create a new folder and name it logically, e.g.,
yourtheme-child
.
Step 2: Create a Stylesheet (style.css)
Inside the child theme folder, create a style.css
file and add the following:
/*
Theme Name: YourTheme Child
Template: yourtheme
Author: Your Name
Description: A child theme for YourTheme
Version: 1.0
*/
PRO TIP: The
Template
name must match the exact name of the parent theme’s folder, or the child theme won’t work!
Step 3: Create a Functions File (functions.php)
Next, create a functions.php
file in the child theme folder and add this code to properly enqueue styles:
<?php
function my_child_theme_enqueue_styles() {
$parent_style = 'parent-style';
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), wp_get_theme()->get('Version'));
}
add_action('wp_enqueue_scripts', 'my_child_theme_enqueue_styles');
?>
Why this step? This ensures your child theme loads both its own styles and the parent theme’s styles correctly.
Step 4: Activate Your Child Theme
- Go to Appearance > Themes in your WordPress dashboard.
- Find your newly created child theme.
- Click Activate.
That’s it! Your child theme is now active, and any modifications you make will override the parent theme without being lost during updates.
What Can You Do with a Child Theme?
Now that your child theme is up and running, here’s what you can customise:
- Modify CSS Styles – Add custom styles in
style.css
. - Edit Theme Templates – Copy and modify files like
header.php
,footer.php
, orsingle.php
from the parent theme. - Add Custom Functions – Extend functionality by adding custom PHP code to
functions.php
. - Create Custom Templates – Build unique layouts for pages or posts.
PRO TIP: Always copy files from the parent theme before modifying them to ensure they remain functional.
Final Thoughts
Using a child theme is a must for anyone customising a WordPress theme. It keeps your changes safe, lets you update the parent theme without worry, and provides a flexible way to modify your website.
If you’re running a WooCommerce store, using a child theme can help tweak templates and improve the checkout experience without risking core functionality.