Skip to main content

What is a Wordpress Child Theme and how does it work ?


According to WordPress Codex, a WordPress Child Theme” is a theme that inherits the functionality of another theme, called the parent theme, and allows you to modify, or add to, the functionality of that parent theme“.
It is very easy to create a WordPress child theme from an existing theme (which then will become its parent theme).
Everything starts by creating a new directory inside the WordPress themes directory, giving it the name we chose for the new child theme. As soon as we put a properly formatted style.css file inside that directory a new child theme is born, without having to wait for 9 months (just kidding) and even if we don´t include any CSS rule at all!

The basics

That´s right. We only need to include the appropriate comment lines in the information header of the style.css file to let WordPress know what is the name of our new child theme, what theme is its parent (acting as a template) and other optional information such as our theme´s  version, the name of the authors, our URI, etc.
In this basic post, we will not get into the details of creating a child theme, but there are lots of great posts and pages out there where you can get them. The only purpose of this post is understanding what a child theme is and what it is useful for. 
We will see how easy is to create a child theme in a future post. For the time being, all we need to know is that any style change made in the child theme to any element of the theme will override that of the parent theme, while any function added to the child theme will add to the functions of the parent theme.

Of children, parents, twins, and clones

Now, if we create a child theme that doesn´t add any new code to the parent theme, we will end up having a “new” theme that, although having a new name (and possibly a new “author”, description, etc.), is nothing but a mere copy of its parent theme. In other words, from my point of view, that should never be called a child theme but a twin-theme! (or a clone theme, for that matter).
But if we start adding or modifying styles and/or functions to our child theme, it will little by little begin looking different from its parent theme. The child, therefore, develops, “grows up” and ceases being a twin of its parent, acquiring its own “personality”.  But even if the changes are numerous with a high level of customization, the child theme will still show some “family resemblance” to the parent theme, since it started by inheriting each and every one of its features from it.

Preserving our work

At this point, somebody might argue that any level of customization could also be accomplished by directly modifying the parent theme, without the need of a child theme. So, why would we bother to create a new child theme?
The answer to that question is simple: because we don´t want to eventually throw all our work away.
Imagine you installed a new theme for your WordPress site and wanted to tweak it a little bit, for example by changing the fonts and some colors. You go to the theme´s style.css file and edit a few lines to make those changes. The results please you but then you think that it would also be nice to change some margins and paddings, so you edit the stylesheet again. And then, later on, you decide to change or add some functionality by editing the theme´s functions.php file. So little by little you´re adding a little tweak here and a little tweak there. Then you are finally proud of your customized theme, you love it and therefore you plan to keep it that way and to always use it for your site, whether it is a  personal blog or a business site.
But one day you realize that, for whatever reason, you should update the original theme (think for example of a functional or security issue you hadn´t noticed before, or a bug you discovered in that theme that has already been fixed by its author in a new release of the theme). Now you would be running into trouble since every time you update your theme to a new version you are actually replacing some of the old files with new ones, which means that you would be overwriting all your custom changes. You´ll be really throwing all your previous work away!
Even if you have a backup copy of the files you tweaked, you´d need to manually redo all the modifications to the new theme´s files again. It wouldn´t be safe to just replace the applicable newly installed files with your backup copies since then you might be also deleting the changes made by the theme´s author to the new version.
The solution? Don´t ever touch the original theme´s files, start by creating a child theme from the first moment you want to modify something in your theme instead.
That way, you´d be free to update the parent theme every time you want, without losing your previous work. Since the changes in your child theme´s stylesheet will override the applicable rules of the parent theme, and your functions will add to the functions of the parent theme (you can even change them without touching the parent theme files), you will be effectively preserving your work.
Your child theme´s files will always keep untouched after a parent theme update, so your modifications to the theme features will never get lost, no matter how heavy your customizations were.

Comments

Popular posts from this blog

How to get 100+ Votes on Inbound

This is not a complex, statistical study but a basis to understand the types of content that work on Inbound. We’ve analyzed everything with 100 or more votes at Inbound.org to get an idea of the topics that get the most attention and upvotes. Content that works at Inbound.org will most likely click with your target audience as well. This analysis will be of great help for anybody looking for topics to woo the B2B audience. Existing work on the topic? We’ve tried searching for posts on similar topics but I found just a couple. This one barely scratches the surface. It makes some valid points like the length or the person submitting the posts matters but most of these findings are not practical or makes much sense. For example, the posts submitted in the month of January will do well or title length is everything. There’s another analysis but with similar results though it mentions that AMA and Google related topics get the most views. We are more interested in the real thing i.e.

How to Generate High Traffic Through Forums

Forum marketing might be the most underutilized traffic generation strategy on the planet. Industry forums are a watering hole of potential leads and customers. However, simply creating a signature and leaving generic posts isn’t going to get you a tidal wave of traffic. I’m going to show you how you can drive targeted traffic to your site using forum marketing. In my Google Analytics, I checked my referral traffic for the month of May, which is a month where I did quite a bit of forum marketing. In the top ten of my referral traffic sources, USA stock Forum is number three. It brought me, 387 visitors. In a different internet marketing forum, Dimeforum brought me 121 targeted visitors. Now, I’m going to teach you how you can do the same thing for your site, no matter what niche you’re in. The first step is to find forums in your niche that are active. This is the best search string you can probably use. You want to use your keyword in quotes plus forum. Depending on yo

What you have to know before investing in Dropshipping?

Dropshipping works for somebody and for somebody it doesn't. Maybe more real empathetic individuals are not so successful as more cold assertive individuals who don't care about selling any nonsense to anybody and fast (they are probably same in the real life, they don't care about people at all).  I am in the drop shipping already from January 2018 and I don't even want to say how much money I have spent and earned maybe 200$ back. Instagram stories are not working (only for somebody) Pinterest is not working (only for somebody) FB ads are very difficult and everything is very saturated.  When you find a "winning product" somebody is already "mining in the same mine with a 5K budget a day" so your future audience is becoming very drained quickly.  In dropshipping, you must try everything and anything and spend loads of money at the beginning and never give up. I was following all the great ideas from Roberto videos and youtube videos and