Child theme

A Child Theme in WordPress is a theme that inherits the design, features, and functionality of another theme – called the parent theme – while allowing you to safely customize and extend it without modifying the parent theme directly.

Why Use a Child Theme?

Modifying a parent theme directly means your changes can be overwritten during updates. A child theme protects your customizations, making them upgrade-safe.

What a Child Theme Includes

At minimum, a child theme contains:

  1. style.css – with a required comment block to define the theme and point to its parent.
  2. functions.php – to enqueue styles or add theme-specific PHP code.
  3. (Optional) Template files – like header.php, single.php, or page.php if you want to override or extend them.

Example: style.css for a Child Theme

/*
Theme Name:     My Custom Child Theme
Template:       twentytwentytwo
Version:        1.0
*/

Template must exactly match the folder name of the parent theme.

Example: Enqueueing the Parent Styles in functions.php

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

When to Use a Child Theme

  • You want to tweak templates or PHP logic.
  • You need to add custom functions or filters.
  • You’re building on top of a framework or premium theme that gets updated regularly.

When Not to Use One

  • If your changes are purely CSS and minimal, you can often use the Customizer or a custom CSS plugin.
  • If you’re building an entirely new design from scratch, a custom theme may be better.

Summary

FeatureDescription
PurposeSafe customization of a parent theme
InheritsStyles and templates from parent
Created withstyle.css, functions.php
BenefitUpdate-safe, modular customization