What is a child theme and how do I create one in WordPress?

Applies to: WordPress.org (self-hosted)
Last updated: May 2025


Problem

You want to customize your WordPress theme (like editing CSS or template files) but don’t want those changes to be lost when the theme updates.


Solution

A child theme is a separate theme that inherits the design and functionality of a parent theme, allowing you to safely make modifications. This way, when the parent theme is updated, your customizations remain intact.


Why Use a Child Theme?

  • Keeps your changes separate from the original theme
  • Prevents customizations from being overwritten during updates
  • Enables deeper customization (PHP, CSS, functions) than what’s possible through the Customizer or page builders

How to Create a Child Theme (Manual Method)

Step 1: Create a New Folder

  1. Access your site’s files via FTP or File Manager in your hosting control panel
  2. Navigate to /wp-content/themes/
  3. Create a new folder for your child theme (e.g., yourtheme-child)

Step 2: Add a style.css File

Create a file named style.css in the child theme folder and include the following:

/*
Theme Name: Your Theme Child
Template: yourtheme
Version: 1.0
*/

@import url("../yourtheme/style.css"); /* For older themes, optional */

Replace yourtheme with the directory name of the parent theme (case-sensitive).

Note: @import is optional and outdated—enqueue the parent stylesheet via functions.php instead for modern best practices.

Step 3: Add a functions.php File

In the same folder, create a file named functions.php and add:

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

This ensures the parent theme’s styles are loaded properly.


Step 4: Activate the Child Theme

  1. Go to Appearance > Themes in your WordPress dashboard
  2. Find your child theme and click Activate

Your site will now use the child theme but still look and behave like the parent theme—unless you add your own customizations.


What Can You Customize?

Once the child theme is active, you can safely add or modify:

  • CSS in style.css
  • PHP functions in functions.php
  • Custom templates (e.g., header.php, page.php) by copying them from the parent theme and modifying as needed

Alternative: Use a Plugin

If you prefer not to create a child theme manually, use a plugin like:

  • Child Theme Configurator
  • WP Child Theme Generator

These tools generate and activate a child theme automatically.