Last Updated on April 14, 2018 by WebsiteDesigner.sg
As a freelance web designer in Singapore, i have put off learning child themes for a long time. I would directly add code blocks to functions.php to modify and customise websites. These changes definitely work and have its own benefits.
But recently whenever i research in the internet on how to modify code on wordpress, i’ve been encountering so many articles that advocate child themes. I know it is good thing to have but maybe a luxury. So anyway, i had the time to check it out and wow, immediately i saw how child themes benefit my workflow and development.
So why are people advocating child themes?
They claim that when you modify directly your changes may disappear upon theme changes. Yes, that would happen to an amateur user but it is NOT a life and death matter. Your changes will NOT vanish into thin air if you use cheap hosts that do not keep your files backed up for you for free or you don’t have a practice of backing up your own files on a regular basis. So this fear of loss of code is not a big thing, in fact, it’s nothing much to a seasoned WordPress developer.
So here are some benefits i saw while programming.
It does not mean that child themes are a waste of time. But they do take up some time to setup if you don’t have the knowledge to do so.
I found out that it is not too difficult at all.. i thought it was going to take me a day or two to learn this.
here are some points
- Create a directory and name it (theme name)-child
- Create 2 files: functions.php and styles.css
- in styles.css you have to add a comment block that tells WordPress the child theme name, versions, etc.
- in functions.php you have to add a code to add styles.css to the queue so that your child theme files will load in the parent theme as the server processes the files.
So if i want to change something in the header.php for example,
I have to copy and paste the header.php file from parent to child and the file path must be the same.
I’ve got a question though. What if the theme updates? Do i have to keep pasting from parent to child again? Isn’t that a waste of time? I’ll update here once i find out.