Skip to main content

WordPress Child Theme: Creating and Configuring One

WordPress · 19.04.2026 · 6 min read
Illustration for “WordPress Child Theme: Creating and Configuring One”

A child theme is a separate WordPress theme that inherits all the functionality and styles of a parent theme but lets you make changes safely. Without a child theme, any parent theme update will wipe out your edits.

Why You Need a Child Theme

When you edit the parent theme's files directly, the next update overwrites all your changes. A child theme solves this: your changes are stored separately and survive updates.

✅ Always use a child theme for any customization — even if you just want to change one line of CSS.

Creating a Child Theme Manually

Create a folder wp-content/themes/your-child-theme/ and two files:

style.css

/*
Theme Name:   My Child Theme
Template:     twentytwentyfour
Description:  Child theme for Twenty Twenty-Four
Version:      1.0
*/

/* Your custom styles go here */
.site-header {
    background: #1a1a2e;
}

functions.php

<?php
add_action('wp_enqueue_scripts', 'child_theme_enqueue_styles');
function 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')
    );
}
⚠️ Template must match the parent theme's folder name (for example, twentytwentyfour).

Child Theme Structure

FilePurpose
style.cssTheme metadata + your styles
functions.phpEnqueues parent styles + hooks
screenshot.pngPreview in the themes panel (880×660 px)
template-parts/Overridden template parts

Overriding Templates

Copy the file you need from the parent theme into the child theme folder using the same path — WordPress will automatically use the file from the child theme:

# For example, to override header.php:
cp wp-content/themes/twentytwentyfour/header.php    wp-content/themes/my-child-theme/header.php
# Now edit the child file
💡 Activate the child theme via Admin → Appearance → Themes. Make sure the parent theme is also installed.

Common Child Theme Errors

Message or symptomCause
The parent theme is missingThe Template field in style.css names the wrong parent theme folder — a typo or wrong case
Child theme styles aren't appliedThe child stylesheet is enqueued at the same priority as the parent, and the parent loads later
Fatal error: Cannot redeclare functionA function with the same name is already declared in the parent theme — rename the function in the child theme
The site looks unstyled after switching themesThe child theme is active, but the parent theme was removed from wp-content/themes

Child Theme vs a Customization Plugin

CriterionChild themePlugin with hooks
Overriding theme templatesYes, by directly copying filesNo, only through filters and hooks
Survives a theme switchNo, tied to the parent themeYes, works with any theme
Good for styles and markupYes, the main toolLimited
Good for business logicNot recommended to mix inYes, logic belongs in a plugin

When a Child Theme Isn't a Fit

  • The changes don't touch templates or styles but add functionality (custom post types, integrations) — that calls for a separate plugin
  • The parent theme is a page builder with its own visual editor that doesn't read child theme files
  • A full theme switch is planned soon — overridden templates would need to be rewritten for the other theme anyway
  • The changes are only to page content, not code — the block editor is enough for that

Verifying the Result

# Confirm the child theme, not the parent, is active
wp theme list --status=active --fields=name,status

# Confirm the child theme's style.css is actually served to the browser
curl -sI https://example.com/wp-content/themes/my-child-theme/style.css

If wp theme list shows the parent theme as active, the child theme activation didn't take — go back to the Template field in style.css. Related reading: speeding up WordPress and WP-CLI commands.

Child Themes and Builders Like Elementor/Divi

If a site is built with a visual page builder, some customizations (global styles, header and footer templates) live in the builder's own database tables, not in theme files. A child theme is still useful for editing style.css and functions.php in that case, but it doesn't replace backing up the builder's settings — export those separately through the builder's own template export/import, or moving the theme to another site won't carry over the layout built in the page builder.

Frequently asked questions

What happens to the site if the parent theme gets deleted while the child theme is active?

The site loses its styling and much of its functionality: a child theme only stores your changes and doesn't contain the full layout code — it pulls in the parent's styles and templates through functions.php. Without the parent theme present, WordPress has nothing to inherit from, so the site visually falls apart even though the child theme stays technically active.

Do I still need a child theme for a site built with Elementor or Divi?

Yes, but its role is limited: edits to style.css and functions.php are still protected from parent theme updates. However, the builder's own global styles and header/footer templates live in the database rather than in theme files, so a child theme won't carry them over when you move the site — export those separately through the builder's own template export tool.

Can I name a function in the child theme the same as one in the parent theme?

No — if the parent theme already declares a function with that name, redeclaring it in the child theme triggers a fatal PHP error. The fix: give the child theme's function a unique name with its own prefix, then hook it in through add_action or add_filter, rather than relying on the name matching the parent's function.

What should I do if I need a custom post type or complex functionality rather than just style changes?

For functionality like custom post types or integrations, a child theme isn't the right tool: that code disappears the moment the theme is switched. Logic like that belongs in a separate plugin, which survives any theme change, while the child theme stays focused on styles, markup, and template overrides.

Was this article helpful?
← Back to Knowledge Base Ask Support