Tutorial · wordpress · Published 2026-08-16 · 3 min read
Create a WordPress child theme
Create a WordPress child theme: the functions.php and style.css setup, why overrides stay safe, and update discipline.
Why a child theme
A child theme is a theme that explicitly inherits from a parent theme. It lets you override styles and template files in one place while the parent theme still provided the base. When you edit a theme directly, a theme update overwrites your changes. A child theme keeps the customization separate from the parent, so updating the parent does not erase your edits.
The best time to split is before you start editing, not after the theme is already customized. Anything you have already changed in the parent has to be re-created in the child, so starting a child early pays off.
The two required files
A child theme needs only a directory, a style.css, and a functions.php. Create a directory under /wp-content/themes/ (for example mytheme-child) that should match the naming that WordPress expects, then add two files.
style.css carries the header that tells WordPress the theme is a child of the parent:
/*
Theme Name: My Theme Child
Template: mytheme
*/
The Template: line must match the parent theme's folder name exactly. Add a @import-free enqueue in functions.php, which is the recommended way instead of @import because the stylesheet and its dependencies load at the right point:
add_action( 'wp_enqueue_scripts', function() {
wp_enqueue_style(
'mytheme-parent',
get_template_directory_uri() . '/style.css'
);
wp_enqueue_style(
'mytheme-child',
get_stylesheet_directory_uri() . '/style.css',
array( 'mytheme-parent' )
);
} );
After that, activate the child theme in Appearance > Themes and confirm the site styles match the parent.
Keep the overrides safe
- Override, do not fork. Only copy a template file into the child when you must change it, and mirror the same path so the child version is used.
- Hook over the function. Add or extend functionality with hooks and filters in
functions.phpinstead of copying whole parent templates. - Update the parent within reason. A child survives parent updates, but a major parent version change can break child-overridden templates; test on a staging copy first.
- Check the minimum version. Some parent themes require the child header to also declare a supported version; if the parent needs it, add
Version:to the child.
| Alternative | Change survives parent update? | Note |
|---|---|---|
| Edit parent theme directly | No | Overwritten on update |
| Child theme override | Yes | Recommended |
| Plugin with hooks | Yes | Best for function-level tweaks |
The WP-CLI theme activation guide shows how to switch to the child theme from the command line, and if a change lands wrong, the troubleshooting order is where to start instead of editing files blindly. When a child theme breaks a page, the cause is often a theme conflict of the same kind covered under plugin-caused errors, so follow the same isolation steps.