How to create and use a WordPress child theme
Editing a WordPress theme's files directly works, until the theme's next update: every customisation then disappears without warning. A child theme fixes this with just two files.
/*
Theme Name: Mon Thème Enfant
Template: nom-du-dossier-du-theme-parent
*/
add_action('wp_enqueue_scripts', function () {
wp_enqueue_style('parent-style', get_template_directory_uri() . '/style.css');
});
Creating the child theme
-
Create a new theme folder
In wp-content/themes, create a folder dedicated to the child theme, separate from the parent theme's folder, which must never be edited directly.
-
Create the style.css file
The file header needs a theme name and, crucially, the Template line, which must exactly match the parent theme's folder name, case-sensitive.
-
Create the functions.php file
This file needs to enqueue the parent's stylesheet before adding the child's own customisations, so the parent's styles always apply as a baseline.
-
Activate the child theme
From Appearance, Themes, the child theme appears as a fully installed theme and activates the same way as any regular theme.
-
Add customisations progressively
Any file from the parent theme can be copied into the child theme unchanged to be edited there; WordPress then automatically uses the child theme's version instead of the parent's.
Why this mechanism protects customisations
When a child theme is active, WordPress first looks for each template file in the child theme's folder. If it isn't found there, it automatically falls back to the matching file in the parent theme. This means only the one file being changed needs to be copied into the child theme, rather than duplicating the entire parent theme.
When the parent theme is updated, only the files in the parent folder get replaced by the new version: the child theme's files stay untouched, since they live in a completely separate folder. That's what makes customisations survive updates, unlike a direct edit to the parent theme, which would be overwritten at every update.
Common mistakes
- Copying every file from the parent theme into the child theme instead of only the ones actually being changed, which cancels out the benefit of the parent's future updates for everything else.
- Getting the folder name wrong on the Template line: a different case or an incorrect name stops WordPress from linking to the parent theme, and the child theme can't be activated.
- Forgetting to keep the parent theme installed: WordPress needs both themes present, since the parent is never activated directly but remains essential for the child to work.
- Trying to change a parent PHP function by redeclaring it identically in the child theme, which triggers a redeclaration error rather than a clean override.
Frequently asked questions
Does a child theme slow down the site?
Can a child theme be created from any parent theme?
Is a child theme needed even for small CSS tweaks?
Describe your need in one minute
A few targeted questions so I can reply with an estimate rather than another questionnaire.