Skip to content

How to Create Child Theme in WordPress

Creating a child theme in WordPress lets you customize your website safely without affecting the parent theme. This guide walks you through the entire process, from setup to activation, ensuring your modifications stay intact during updates.

Key Takeaways

  • Preserve Customizations: A child theme protects your changes when the parent theme updates.
  • Easy to Set Up: You only need a few files and basic knowledge of HTML and CSS.
  • Safe for Beginners: No risk of breaking your site—ideal for testing design tweaks.
  • Supports Advanced Features: You can override templates, add functions, and enqueue custom styles.
  • Improves Performance: Only loads necessary code, keeping your site fast and efficient.
  • Works with Any Theme: Compatible with most WordPress themes, including popular ones like Astra and Twenty Twenty-Four.
  • Essential for Developers: A must-know skill for anyone managing WordPress sites long-term.

Introduction: Why Create a Child Theme in WordPress?

If you’ve ever customized a WordPress theme—changed colors, tweaked layouts, or added custom code—you know how frustrating it is to lose those changes after a theme update. That’s where a child theme comes in. It’s a safe, smart way to modify your site while keeping the original (parent) theme intact.

In this guide, you’ll learn how to create a child theme in WordPress from scratch. Whether you’re a beginner or a seasoned developer, we’ll walk you through every step with clear instructions and real-world examples. By the end, you’ll have a fully functional child theme ready for customization.

What Is a Child Theme?

A child theme is a theme that inherits the functionality and styling of another theme, called the parent theme. It allows you to make changes—like adding custom CSS, modifying template files, or adding new features—without altering the parent theme’s core files.

How to Create Child Theme in WordPress

Visual guide about How to Create Child Theme in WordPress

Image source: webstick.blog

This is crucial because when the parent theme receives an update (for security, performance, or new features), your customizations won’t be overwritten. Think of it like building a house extension: you keep the original structure safe while adding your personal touch.

Prerequisites: What You Need Before Starting

Before diving in, make sure you have:

How to Create Child Theme in WordPress

Visual guide about How to Create Child Theme in WordPress

Image source: wpnewsify.com

  • A WordPress website installed and running.
  • Access to your site’s files via FTP, cPanel File Manager, or your hosting provider’s file editor.
  • Basic knowledge of HTML and CSS (helpful but not required).
  • A parent theme already installed (e.g., Twenty Twenty-Four, Astra, or GeneratePress).

Don’t worry if you’re new—this process is beginner-friendly and doesn’t require coding expertise.

Step 1: Choose Your Parent Theme

The first step is selecting the theme you want to build upon. Most modern WordPress themes support child themes, but it’s best to use well-coded, regularly updated themes.

Popular Parent Themes for Child Themes

  • Twenty Twenty-Four: Default WordPress theme, lightweight and well-documented.
  • Astra: Highly customizable and performance-optimized.
  • GeneratePress: Fast, flexible, and developer-friendly.

For this guide, we’ll use Twenty Twenty-Four as the parent theme, but the process is the same for any theme.

Step 2: Create a Child Theme Folder

Child themes live in the /wp-content/themes/ directory. You’ll need to create a new folder for your child theme.

How to Create the Folder

  1. Log in to your hosting account and navigate to public_html/wp-content/themes/.
  2. Create a new folder. Name it something clear, like twentytwentyfour-child.

Tip: Avoid spaces or special characters in the folder name. Use hyphens or underscores instead.

Step 3: Create the style.css File

Every WordPress theme needs a style.css file. This file tells WordPress about your theme and loads the parent theme’s styles.

How to Create style.css

  1. Inside your child theme folder, create a new file named style.css.
  2. Add the following header information:
/*
Theme Name: Twenty Twenty-Four Child
Theme URI: https://example.com/twentytwentyfour-child
Description: Child theme for Twenty Twenty-Four
Author: Your Name
Author URI: https://example.com
Template: twentytwentyfour
Version: 1.0.0
*/

The most important line is Template: twentytwentyfour. This must match the folder name of the parent theme exactly—case-sensitive!

Enqueue Parent and Child Styles

Next, you need to load the parent theme’s stylesheet. Add this code to your style.css file after the header:

@import url("../twentytwentyfour/style.css");

Note: While @import works, it’s better to use functions.php for enqueuing styles (we’ll cover that next).

Step 4: Create the functions.php File

The functions.php file lets you add custom functionality to your child theme. It runs after the parent theme’s functions, so you can override or extend features.

How to Create functions.php

  1. In your child theme folder, create a new file named functions.php.
  2. Add this code to properly load the parent and child styles:

This ensures the parent theme’s CSS loads first, then your child theme’s styles override it.

Step 5: Activate Your Child Theme

Now that your child theme is ready, it’s time to activate it.

How to Activate the Child Theme

  1. Go to your WordPress dashboard.
  2. Navigate to Appearance > Themes.
  3. You should see your new child theme listed (e.g., “Twenty Twenty-Four Child”).
  4. Click Activate.

Your site will now use the child theme. Visit your site to confirm everything looks correct.

Step 6: Customize Your Child Theme

Now comes the fun part—customizing! Here are a few common ways to modify your child theme.

Add Custom CSS

Open your style.css file and add your own styles. For example:

.site-header {
    background-color: #2c3e50;
    color: white;
}

h1 {
    font-family: 'Georgia', serif;
}

These changes will override the parent theme’s styles.

Override Template Files

Want to change how a page looks? Copy a template file from the parent theme into your child theme folder and edit it.

For example, to modify the header:

  1. Copy /wp-content/themes/twentytwentyfour/header.php.
  2. Paste it into your child theme folder.
  3. Edit the file as needed.

WordPress will use your child theme’s version instead of the parent’s.

Add Custom Functions

Use functions.php to add new features. For example, to add a custom widget area:

function my_child_theme_widgets_init() {
    register_sidebar(array(
        'name' => 'Custom Footer Widget',
        'id' => 'custom-footer-widget',
        'before_widget' => '',
    ));
}
add_action('widgets_init', 'my_child_theme_widgets_init');

Troubleshooting Common Issues

Even with careful setup, you might run into problems. Here’s how to fix the most common ones.

Child Theme Not Showing Up

  • Check the folder name and location: It must be in /wp-content/themes/.
  • Verify the style.css header is correct, especially the Template line.
  • Ensure the parent theme is installed.

Styles Not Loading

  • Make sure functions.php is enqueuing styles correctly.
  • Clear your browser and WordPress cache.
  • Check for typos in file paths.

Changes Not Appearing

  • Ensure you’re editing files in the child theme, not the parent.
  • Use browser developer tools (F12) to inspect elements and see which CSS is applied.
  • Try adding !important to CSS rules if needed (use sparingly).

Best Practices for Using Child Themes

To get the most out of your child theme, follow these tips:

  • Keep It Light: Only add what you need. Extra code can slow down your site.
  • Document Changes: Comment your code so you remember what you did later.
  • Test Regularly: Check your site after WordPress or theme updates.
  • Use a Staging Site: Test changes on a copy of your site before going live.
  • Backup Often: Always backup your site before making major changes.

For more on managing themes safely, check out our guide on how to update a theme on WordPress to avoid breaking your site.

Conclusion: You’ve Successfully Created a Child Theme!

Congratulations! You now know how to create a child theme in WordPress and why it’s one of the best practices for site customization. With a child theme, you can safely tweak your site’s design, add new features, and keep everything intact during updates.

Whether you’re adjusting colors, adding custom widgets, or overriding templates, your changes are now protected. This skill is essential for anyone serious about WordPress development—and it only takes a few minutes to set up.

Ready to take your site further? Explore our guide on the best way to add CSS in WordPress to enhance your styling workflow. And if you ever need to switch back, learn how to deactivate a theme in WordPress safely.