Categories
Featured

What is WordPress Child Theme & When to Use One

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?

Decisions

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.