Child themes: safe customisation
Create a child theme so your changes survive parent updates: the style.css header, overriding templates, functions, updating safely and troubleshooting, with a real test.
In this lesson you will
- Create a child theme
- Override templates and styles
- Decide between theme and plugin
- Update safely
About 16 minutes
Changing a theme without losing your changes
Rania edits her theme’s footer file directly to add her phone number. It works for three months. Then she clicks Update on the theme, and the phone number vanishes, because the update replaced every file with a fresh copy. The professional answer is a child theme: a small theme that sits on top of a parent theme, inherits everything and keeps only your changes. When the parent updates, your changes stay safe. This is the first rule of advanced WordPress work: never edit a theme you did not write.
How a child theme works
A child theme needs only a folder with a style.css file whose header names the parent in a line called Template. WordPress then loads the child’s files first and falls back to the parent for everything else. A test built a child theme of the site’s real theme, asked WordPress what it saw, then broke the link on purpose to see the error, and deleted the folder. The output is real:
child exists: yes | name: Zz Child
parent (Template header): skillsinminutes | parent name: Skills in Minutes
files in child folder: functions.php, header-note.txt, style.css
child is a block theme: no
parent's file count (top level): 18 php files stay in the parent
child pointing to a missing parent: The parent theme is missing. Please install the "no-such-parent" parent theme.
cleaned: yes
WordPress recognised the child from its header, found the parent by name and listed the files in the child folder. When the Template line pointed to a parent that does not exist, WordPress reported a clear error instead of crashing. The parent’s PHP files stay in the parent folder; the child holds only what you add or replace.
The minimum child theme
/*
Theme Name: My Child
Template: parent-folder-name
Version: 1.0
*/
The Template value is the parent’s folder name, not its display name. For a classic parent theme, add a functions.php to load extra code or styles. A common pattern is to add your own stylesheet after the parent’s, so that your rules win. Check the parent theme’s documentation, because some themes already load their own styles in a way that needs no extra step.
What you can override
| You want to change | In the child theme |
|---|---|
| A template such as the footer | Copy that file into the child and edit the copy |
| Styles | Add rules in the child style.css |
| Behaviour | Add hooks in the child functions.php |
| A whole page layout | Add a custom template file |
Copy only the files you need to change. A child with fifty copied files is hard to maintain, since each copy stops receiving the parent’s fixes. Block themes work differently: you can customise with the Site Editor, and a child theme holds your saved changes and extra patterns. The idea is the same, and the details change with the theme.
Child theme or plugin?
Ask where the change belongs. If it concerns how the site looks, it belongs in the child theme. If it concerns what the site does, such as a custom content type or a shortcode, it belongs in a plugin, so the feature survives a change of theme. Mixing the two is a common reason why content seems to vanish after a redesign.
Updating safely
- Take a backup (lesson 9).
- Test updates on a staging copy if the site matters to a business.
- Update the parent theme.
- Check the pages that use overridden templates, because the parent’s version may have changed.
- Compare your copied files with the new parent versions and merge needed fixes.
Troubleshooting
- The child does not appear in Themes: check the folder location and the header.
- The site looks unstyled: the parent styles may not be loaded; check how the parent expects children to load them.
- A white screen: a PHP error in functions.php; fix or rename the file through your host’s file manager.
- Changes do not show: clear caches and test in a private window.
Practice
On a practice site, create a child theme for your active theme. Change one colour in style.css and override one template, such as the footer. Update the parent (or simulate it by editing the parent’s version number on a copy) and confirm your changes survive.
If the colour change works and survives the update, the child theme is doing its job. Keep a short README in the child folder listing each override and why you made it; it saves time in a year.
Editing the parent theme directly ‘just this once’. The next update erases it and nobody remembers what changed.
A worked scenario
A client’s site uses a popular theme and wants a new footer with an opening-hours line and a different brand colour. The plan: create a child theme, add the colour rule to its style.css, copy the footer template into the child and edit the copy, and write a one-page note listing both changes. Six months later the parent theme releases a security update. Because the changes live in the child, the update is applied in minutes, and only the copied footer needs a quick comparison with the parent’s new version. Without a child theme the same update would have erased the client’s work.
| Task | Where it lives |
|---|---|
| Brand colour | Child style.css |
| Opening-hours footer | Copied footer template |
| Change log | README in the child folder |
Check what you learned
Five quick questions. Pick an answer and you will see straight away whether it is right and why.
What is a child theme for?
- Making the site faster
- Keeping your changes safe when the parent updates
- Replacing WordPress
- Storing posts
It inherits from the parent.
Which header line names the parent?
- Version
- License
- Author
- Template
It holds the parent’s folder name.
Where should a custom content type live?
- In a plugin
- In the child theme only
- In the media library
- In a widget
Features belong in plugins.
What did WordPress report when the parent was missing?
- Nothing
- A new parent
- A clear error message
- A crash with no message
The real test showed it.
How many files should a child copy?
- All of them
- None, ever
- Only images
- Only the ones you change
Copies stop receiving parent fixes.
Summary
- Never edit a theme you did not write.
- A child needs a folder and a style.css with Template.
- Copy only what you change.
- Features belong in plugins, looks in the child theme.
Questions
Do I need a child theme for a block theme?
Not always. The Site Editor stores your changes in the database. A child theme is useful for shipping changes with code.
Will a child theme slow my site?
Hardly at all. It adds one small folder; what matters is what you put in it.
Can I switch parents later?
Not easily. A child is tied to its parent's structure, so changing parents usually means rebuilding the child.
