WordPress Child Theme – How Does It Work?

Here’s the short potential scenario of why you might consider using WordPress child theme. Let’s say that you chose a WordPress theme that you like, and you installed it successfully. Next, you decided to introduce some changes. You customised its design slightly, so it better suits your preferences. After some time, you logged in to your WordPress dashboard and noticed that there is an update available for your theme. Upgrades are essential because they make your website secure. You clicked on the update button and then opened your site in the web browser to find out that all changes to its design are gone. It is because you introduced them to the original theme. Consequently, after the update, all CSS styles that you have added will be lost. So, is there a way to customize a chosen theme without compromising on upgrades? Yes, and the solution is the child theme. Resigning from updates is never good. It can lead to breaking your site and it will leave it available to hackers. Developers make updates to themes to make sure that they comply with the latest WordPress standards.

What is WordPress child theme?

First of all, I would like to explain the difference between WordPress theme customizer and customizing a theme by introducing changes into code. Any changes that you make by using WordPress theme customizer are being saved in a database. It means that updates to the theme will not override them. If you, however, plan to make some changes to the CSS, HTML or JavaScript of your original theme, you may need to install the child theme. That way, you can safely upgrade the original theme anytime a developer updates it and still keep all the changes you have made. Child themes are also a great way to play with a code and learn it. It is because all the changes you make are on the top of a parent theme. It gives you the better idea of how things work. Also, if you do anything you do not like to your child theme, you can always delete it. It will not affect the original theme in any way. All in all, the child theme is a WordPress theme, that inherits all the design and functions from its parent theme. Parent theme is the original theme that you chose for your website.

How to pick a parent theme?

Not all WordPress themes are good to use as a parent theme. It is because not all WordPress themes are theme frameworks. If you want to modify the coreĀ functionality of your chosen theme (custom headers, sidebars, widgets, comments, administration menus and more), you should make sure that the WordPress theme you choose for your website is a theme framework. Theme frameworks allow you to modify and customize the core theme functionalities without touching the core theme files. In conclusion, if you want to introduce basic CSS changes, you can create a child theme to any WordPress theme and it will work fine. On the other hand, if you plan to add some new functionalities to your website or introduce more changes to its design, then you may want to look for the WordPress theme that is a theme framework.

How to install a child theme?

For this, you need to login to your hosting account where you can create a folder for your child theme in wp-content/themes/ directory. (Login to cPanel – go to File Manager – find public_html – next, go to wp-contents and finally find themes folder and open it). Now, let’s say you have chosen Twenty Fourteen WordPress theme for your website. It means that you need to create a folder called twentyfourteen-child in wp-content/themes/directory in order to create a child theme for your original Twenty Fourteen WordPress theme. Once you have the folder saved, create a blank file called style.css (click on +File, name it style.css and save all changes) in there and add some information. The information you need to add are as follows:

/*
Theme Name: Twenty Fourteen Child
Theme URI: https://wordpress.org/themes/twentyfourteen
Description: Twenty Fourteen Child Theme
Author: put your own name here
Author URI: http://www.yourwebsiteaddress.com
Template: twentyfourteen
Version: 1.0.0
*/

Once you are done, you can save the file. You will now need to bring in stylesheets from the parent theme to your child theme. Previously, the @import method was very popular, but it is no longer the best idea to use it. It is because it increases the amount of time for the stylesheets to load. It affects website’s loading speed and speed is one of the most important ranking factors. Ideally, your website’s loading speed should be under five seconds. If it takes more than that, it creates worse user experience. And, because Google wants their customers to have the best user experience possible, it may put higher in searches those websites that load faster than yours. What is the correct way to bring in stylesheets from a parent theme to a child theme, then? You should enqueue the parent and child theme stylesheets by adding wp_enqueue_scripts action and use wp_enqueue_style() in your child theme’s functions.php.

CONCLUSION:

Child theme is a WordPress theme that inherits all the functionalities from the parent theme. There are many advantages of using child themes. One of the most important ones is that you can make changes to your website without modifying the parent theme. You can add many new functionalities to your site. Upgrading the original theme will not override your modifications if you have the child theme installed. The best advantage of WordPress child theme is that you have your theme that you manage and you are still using the parent theme that a developer has built. Finally, child themes are a great way to learn how to build themes. They allow you to experiment by adding alterations on the top of a parent theme. And, if anything goes wrong you can always delete these changes and go back to the original state.