How to develop a WordPress child theme and why you need to have one
More than 35% of wordpress users use a child theme.
WordPress themes are amazing but they aren’t pitch-perfect. Maybe a little background change, or adding a CTA button would make them so, but even the slightest hint of the theme modification starts giving us shudders. WHY? For most users, it is because all the changes are lost with the theme’s latest update. So either you don’t update your theme or let go of the changes you wished for. Now that a dilemma with no choice seeming right. If one really has to go on this road, what other options a developer is left with?
Develop a Child Theme. What?
For those of you who have been a developer for a long time, they know how important it is to build a child theme on an existing theme. Child theme not only allows you to make appropriate changes to a parent theme, but also saves you all the hassle of starting from scratch one. With child theme, not only can you customize a parent theme, but also rest at peace knowing that no future update can alter your modifications. Isn’t that what you wanted in the first place?
YES. So child theme is the answer, but how to develop it?
Well, good news to all the folks out there, creating a child theme isn’t that arduous a task than you probably thought. For those who have a sound understanding of HTML, developing a child theme should be a piece of cake. All you have to do is create one folder and one file.
One folder and one file. That’s it?
Yes. It’s that easy. In this article, I will be showing you how one can go about creating a child theme.
First of all, you will require the access to your website. You can either access your website files via FTP or with the help of your hosting provider’s file manager application. Personally, I will recommend you do the same with FTP account. It is very easy to add folder and file this way. Besides, one can really set up their FTP account very quickly.
Creating Child theme’s folder
Once you have access to your website files via your FTP client, find a folder named “wp-content/themes”. You can find this directory very easily. It will contain a lot of folders, each of which represents the theme that are installed on your website.
Once you are inside this directory, all you have to do is create a new folder. Name it in such a way that you can easily distinguish them with the current folders. It is very important that you remember this name too. Here’s an example,
Creating style.css file
Now that you’ve created the folder, all you need to do is create the only file that is required to develop child theme- a style.css file. It works basically that same way as in any other website development. Firstly you need to add some generic vital information inside your file to get you started. You can use the information given in the example as well or you can also change it according to your need.
Theme Name: My Child Theme
Theme URI: http: //mysite.com/
Description: This is a custom child theme I have created.
Author: My Name
Author URI: http: //mysite.com/
All of the above information can be used as it is. There is only one variable that you need to alter. To make you child theme valid, you need to change the parent theme in Template to the existing parent theme that you want to modify. In our case, it is twentyeleven. Once you are done with changing the template name, you need to call styling file of your parent theme. You can call it by using this instruction
It is but obvious that you need to change the name of parent theme to the name of the theme you chose. If you were to see your child theme without calling your parent theme styling file, you will see blank space. Calling styling file will provide you with the already developed functionality and features of your parent theme. Not only will you be saved from starting from line one, you now have the chance to edit the only portions of your parent theme that you want modified. Now all you have to do is apply your knowledge of HTML and alter or introduce the code that you want in the theme.
Once you have done that, save your edited style.css file to the folder that you created earlier. Now log in to your wordpress account. Go under appearance and activate your Child theme.
That’s all folks
Now tell us honestly, wasn’t creating child theme easy? We bet it was lot easier than you thought it would be. Just a few minor tweaks here and there and you’re done. Now leave all the excuse behind and create the theme that you always desired. All the best!