How to Work with WordPress Child Themes
Some of us work with ready-to-use WordPress themes, such as those purchased from marketplaces like Themeforest. These themes usually come with life-long updates from the developer. If you are into modifying your themes, you will want to make changes in a way that future updates do not override any changes you made. For such a purpose, Child Themes play an important role.
A theme that supports Child Themes is made up of 2 folders: the parent theme folder and the child theme folder (with the suffix -child). The child theme inherits the styles, layout and functionality of the parent theme.
To make any coding changes to the theme, here’s the way to do it.
- Copy over the template file, for eg. single.php, from the parent theme folder into the child theme folder.
- Make changes to the copy of the file in the child theme. This file will override the equivalent file in the parent theme directory when your site loads.
The only exceptions will be for the files functions.php and style.css, for which you should simply add on your own functions and classes/IDs without copying the original files over.