What is a WordPress Child Theme
A WordPress child theme is a WordPress theme that inherits its functionality from another WordPress theme, the parent theme. Child themes are often used when you want to customize or tweak an existing WordPress theme without losing the ability to upgrade that theme. In the past, there was no easy way of updating WordPress themes without losing all the custom styling and changes that you had made. This becomes chaos when all the sudden you find out a widely used script in popular themes has a major exploit, and you need to update your themes ASAP. It becomes a tough choice because on one hand, you would lose all the custom styles if you update. On the other hand, you risk your site getting hacked if you don’t update fast enough.
The core team and the community decided to solve this problem by introducing the concept of parent theme and child theme. A child theme in WordPress would inherit all the functionality, features, and the code of the parent theme without making any changes to the parent theme itself. This allowed users to change the styling of the parent theme and add/modify features without losing the ability to update the parent theme.
In theory, any WordPress theme can have child themes however not all WordPress themes are good parent themes. A parent theme with limited functionality and features is not exactly an ideal parent theme candidate in most cases. We will talk about the exceptions later on in the article.
A good parent theme also known as theme frameworks usually contains its own action hooks and filters. This allows designers and developers to create a robust custom WordPress site using child themes in a fraction of time.
Why do people use WordPress Child Themes?
Designers and developers use child themes to speed up their development. When using a good parent theme, you can drastically reduce the time it takes for you to create a WordPress site. All good parent themes aka theme frameworks offer tons of functionality and customization options, so you don’t have to code everything. DIY users often create child themes to tweak an existing theme without losing the ability to update the parent theme if needed.
Creating a WordPress child theme can be as simple as creating a new style.css file in a new folder. All you really need is one line in your new style.css header that defines the template (see the Codex for reference). A robust child theme can have just as many template files as the parent theme if not more. A child theme can have template files that are not even available in the parent theme.
When Should You Use a Child Theme?
The decision to use a child theme often depends on your needs. Most sites that we build for ourselves and our clients are child themes of the Genesis theme framework. In rare cases when the project is too complex or too simple, then we build it as a standalone custom WordPress theme. As WordPress developers, we need to streamline our workflow while creating quality themes. Creating a child theme of Genesis framework helps us accomplish just that.
For users we recommend child themes only if you find yourself constantly adding new functions to your theme’s functions.php file and/or constantly adding/modifying the style.css file of your theme. In these cases, we highly recommend that you use a child theme. A short while ago during our WordPress meetup talk, one of the members asked us what if you are only adding custom styles? Is it better to use a child theme or a custom CSS plugin?
The answer to that depends on how savvy and comfortable you are with technology. If you are only modifying the styles of a few elements, then using a custom CSS plugin works just fine. However, if you find yourself changing the entire color scheme, moving things around in the CSS, etc, then you definitely should consider using a child theme.
Picking a Good Parent Theme is IMPORTANT
All WordPress frameworks are parent themes, but not all parent themes are frameworks. We cannot stress this enough. While any WordPress theme can have child themes, not all of them are meant to be used as theme frameworks. We have seen numerous beginners who make the mistakes of creating a child theme of a parent theme that doesn’t offer much functionality.
If you are creating a child theme where you find yourself replacing a lot of the parent theme files, then you should rethink your process. For example you really like the Twenty Eleven theme, and you decided to create a child theme. In your child theme, you had the style.css file, and functions.php file. On top of that, you decided that you don’t like the way the footer looks, so added footer.php. Same for header, etc. If this is the case, then you shouldn’t be using Twenty Eleven as a parent theme. Rather you should be using it as a starter theme that you turn into your own custom theme.
We have had several users who created custom child themes which really should be totally independent custom themes because they had overridden almost all of the parent theme files.
In short, you should use a child theme when you need the functionality, features, and awesomeness of a powerful parent theme without writing much code for it yourself.
Advantages of Using a WordPress Child Theme
Like most things, there are advantages and disadvantages to using a WordPress Child theme. Let’s take a look at advantages first.
1. Safe Updates
A child theme automatically inherits the parent theme’s features, styles, and templates. This allows you to make changes to your site using child themes without ever modifying the parent theme. When a new version of the parent theme arrives, you can safely update it as all your modifications are saved in the child theme.
2. Easy to Extend
A child theme built on a powerful theme framework allows a great deal of flexibility without writing a lot of code. You can selectively modify only the template files and functions that you need without going through other template files. You can add new functionality and much more.
3. Fallback Safe
When you are creating a complete theme you need to think about all the possible scenarios and code for them. However, when you are working on a child theme and you forget to code for something, then there is always the parent theme’s functionality available as the fallback option.
Disadvantages of Using a Child Theme
One of the biggest disadvantage of using child themes is the time you need to invest to learn about the parent theme. There is a learning curve specially when you are working with robust frameworks because each of them have their own hooks and filters. You really have to know those to maximize the potential. In our opinion, this learning curve is a one-time thing. For example the first few child themes that you create might take you longer, but after that you will be creating custom websites in a fraction of time. Your overall performance will improve.
Another disadvantage often pointed out is that your parent theme’s developers may loose interest and abandon it, drop a feature that you were using in your child theme, or bring a change that totally destroys your child theme. This is not as bad as it sounds. Mainly because all good WordPress themes are open source and GPL. If the parent theme developer abandons the project, then nothing says that you have to stop using it. Often times, other folks in the community step up to take over the project. If the original theme developers remove a certain feature, then you can simply add it in your child theme. You have the code for it. Lastly, if they make a drastic change that you don’t like, then you can always avoid updating. Theme updates are crucial when there is a security exploit. We always recommend users to update themes because it helps ensure future compatibility with other scripts and plugins.
If you are using a commercial theme framework like Genesis, then you have support option available to help you upgrade your theme or troubleshoot problems. Also a platform like Genesis is not going to just disappear because there is a stable business organization behind it with thousands of customers world wide. For example, they removed certain built-in widgets, but they made them publicly available as plugins for those who still wanted to use it.
It is important to know that even though you can always create a child theme of any WordPress theme, sometimes you may not need a child theme. Think about the number of changes you have planned for your child theme, if the changes you are planning are minor, then you can always create a custom-style.css file in your theme or use a Custom CSS plugin. If the changes are too extreme where you find yourself overriding the core parent theme files, then you probably should be creating a custom theme.