Short answer: if you edit a theme’s files directly and the theme is later updated, the update replaces the files and your changes disappear. A child theme is a small theme that inherits everything from the original and keeps only what you changed. The original can update freely, and your changes stay.
Three ways to change a theme
|
Editing the theme files |
Child theme |
WordPress’s own options |
| Survives a theme update |
No. |
Yes. |
Yes. They are kept in the database. |
| Good for |
Nothing you rely on. |
Changing PHP templates and adding functions. |
Colours, fonts, small CSS, texts, menus. |
| Effort |
None at first. Costly when it is lost. |
Create two files and activate it. |
None. |
| Risk |
A mistake takes the site down, and the update erases your fix. |
The same risk of a mistake, but kept apart from the original theme. |
Low. |
Before creating a child theme, check you need one: small CSS and colours fit in Additional CSS (under Appearance › Customize) on a classic theme, and in Appearance › Editor on a block theme. You only move to a child theme when you want to change a template or add code. Which kind of theme you have is in block theme or classic theme.
How to create a child theme
| 1 |
Take a backup and, if you can, rehearse on a test site: a test site.
|
|
| 2 |
Create a new folder in wp-content/themes, using cPanel’s File Manager, named after the parent theme followed by -child.
|
|
| 3 |
Inside it, create the file style.css with a comment at the top that has two lines: Theme Name: with any name you like and Template: with the exact folder name of the parent theme. If the parent’s folder name is misspelt, the child theme does not appear.
|
|
| 4 |
Also create a functions.php that loads the parent theme’s stylesheet. The standard code is in WordPress’s theme handbook, and some themes ship a ready-made child theme to download.
|
|
| 5 |
Activate the child theme under Appearance › Themes and open the site. Only then start copying into it, one at a time, the parent’s files you want to change, and edit the copies.
|
|
|
Customize options are stored per theme. When you activate the child theme, the page may look as if it lost colours, logo and the place of menus or widgets. It has not: they are with the parent theme. Note down how it was before and set the options again, or rehearse on a test site first.
|
|
Broke the site while editing the theme? Renaming the theme’s folder in cPanel’s File Manager usually gets you back in. Tell us what you changed.
Open a support ticket
|
RECOMMENDED PRODUCT Web hosting with cPanel Domain and SSL included, daily backups and the panel you already know. from $6.59/mo (3-year plan, with coupon) See plans |