Saturday, June 27, 2015

What is a WordPress Child Theme?

WordPress started as a blogging tool, but has grown into a full-fledged content management system for web development. WordPress powers more than 24% of the Internet. Owing to this fact, there are hundreds, if not thousands, of WordPress themes available in the market.


Whenever I start using a WordPress theme, I find myself in a situation where I want to make a few changes to it. But if you make changes in a WordPress theme, then updating it to a new version is one hell of a job. For example, let’s suppose you started using the Twenty Fifteen theme provided by WordPress. You update style.css to change a few things. But then after a few months when theme developers pushed an update for Twenty Fifteen, you’ll be in a position where you could choose to update the theme and lose all your custom styling, or stay out-dated and get hacked, since sometimes theme updates contain security fixes.


Child Themes To The Rescue


This is where concept of Child Themes kick in. Let’s forget about WordPress for a moment. Let’s talk about parents and children. What do you know about children? Being a child, I am bound to get a few characteristics of my parents, but there will also be habits that are pretty unique. Which makes total sense. A child can have some or all traits of their parents with added unique traits of her own.


The concept of Child Themes is based on this fact, and during this entire series I will try to cover all the major aspects of WordPress and Child Themes. So, let’s begin with the first article, which serve as an introduction to child themes. Towards the end of this article, I’ll discuss some of the differences between a parent and a child theme.


Child Themes in WordPress


Normally, all the created WordPress themes are the base themes, or you call them Parent themes. Parent themes bear all the functionality and features which may or may not be inherited by a child theme.


child-themes-chemistry 


Let me explain this concept with a simple example. Imagine that you are a chemist and you are running some experiment. You prepared a solution and you aim to test it further with different types of emulsions. Now, instead of using the entire solution all at once, you divide it into two or three equal parts with each part behaving as a parent. Now if you perform an experiment and it didn’t get the desired results, you will still have a duplicate parent which can be later used for another test. However, if you performed the test on the entire solution, then in case of failure, you may lose the original product (i.e. your parent theme). So, every time you experiment, you have the original parent which has all the features you need. These features can be used as a base while you can add a few unique features in the child which is what a child theme does. Still with me?


The Official Definition


According to the WordPress codex:


A child theme is a theme that inherits the functionality and styling of another theme, called the parent theme. Child themes are the recommended way of modifying an existing theme.



So basically, any theme can behave as a parent theme if it offers the ability of creating a child theme. Now, back to the situation we discussed earlier. If a child inherits features from a parent then what will happen in a case where the parent theme undergoes an update? The answer is simple: only your parent theme will change, while your modifications will stay the same in its Child Theme. So, if you want to keep up with your modifications and still enjoy the latest code base from your theme’s author, all you need to do is create a child theme instead of using the parent theme. We will discuss multiple methods to create a WP child theme in upcoming articles of this series.


Differences between Parent & Child Themes


Now let’s look at some of the differences between parent and child themes.


  • A child theme is related only to its parent theme. Which means that in terms of relevance no other theme bears connection with the child theme.

  • A child theme is dependent upon the parent theme. To make sure that your child works well, you need to install both the parent & the child theme and then activate the later.

  • Parent themes can exist as an independent unit since they are not dependant on any other theme.

  • Updates in the parent theme do not affect your modifications in the child theme.

Conclusion


So now you know a little about child themes. In the next post, we will discuss the advantages and disadvantages of using a Child Theme in WordPress. I’d love to hear your thoughts about this series, so leave me a comment below if you have any questions or requests.



Ahmad Awais is a Full Stack WordPress Developer, WP Core Contributor, Front-end Fanatic and a Designer by night. He loves to create optimized but advanced workflows to produce cool pieces of Open Source software. Follow Ahmad at Twitter or subscribe to his blog.

Products Seen In This Post:


    



getpaidtowrite-banner
What is a WordPress Child Theme?

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.