Frameworks? Parent, child, and grandchild themes?

One question that crops up every once in a while from my theme users is how to create a WordPress grandchild theme. Most of the time, a user asks, “How do I update my child theme? Do I need to create a grandchild theme?”

The idea of parent/child themes became popular because it allowed the parent theme to be updated while keeping customizations intact within a child theme. That system works great. The problems begin when a child theme is updated. Users tend to want to take advantage of the update, but they can’t upgrade because they’ve made customizations.

Essentially, we’ve just added another layer to the preexisting problem.

But, that’s not where the real problem is at. The problem is confusion over what frameworks, parent themes, and child themes are. Users aren’t to blame for this confusion. Theme developers are at fault here (even me), and I’m going to attempt to clear things up.

Advanced parent themes are not frameworks

I’m going to avoid calling any other “framework” themes out and tell you that my own Hybrid theme is not a framework, at least not in the traditional development framework sense. It’s an advanced parent theme. Admittedly, I’ve called it a “framework” before because I’ve just been following the crowd.

What should we call the Hybrid theme? Simple. It’s a parent theme.

One thing we should definitely not confuse are the terms “framework” and “parent theme.” These two are not interchangeable. That’s where a lot of the confusion stems from.

What is a theme framework?

This is the question I most wanted to answer because I'll be releasing a framework for theme developers soon (see below). But, I can't do that with all this confusion floating around the community.

A theme framework is a set of conventions to use for developing WordPress [parent] themes.

Yes, that’s a bit vague, but frameworks can exist for all kinds of different purposes. This can be something like an elegant template engine (Carrington Core is really good for this) or a set of helper functions for more quickly building a theme.

It is not a theme though. You can’t simply drop it in your WordPress themes directory and expect it to work.

Frameworks are for theme developers. They offer a set of standards (or whatever features) for theme developers to use in creating their own themes. They’re a set of functions/features created to aid development.

What is a parent theme?

Nearly all WordPress themes are parent themes. Only those called “child themes” are not parent themes.

Theme developers create parent themes for users to download and install on their sites. My Hybrid theme is, without a doubt, a parent theme. Parent themes should house the theme design, functionality, and the templates required for running the theme in WordPress.

You can use a framework to build a parent theme, but the framework is not a parent theme itself.

What is a child theme?

A child theme is something users should be creating so that they can customize the look and functionality of their site. The child theme inherits all of its functionality from a single parent theme.

When a theme developer creates a child theme, things become problematic because that child theme might eventually need an update. If you’re a theme developer and are building a child theme with a 20kb functions file and five or six custom templates, I can assure you that you’re doing it wrong. I’ve even had to tell myself this.

What you should really be creating is a parent theme. Child themes from theme developers should be nothing more than a stylesheet and a few functions. This idea of releasing advanced child themes just creates the same problem child themes were meant to solve: upgradability.

I’ve got over two years of experience at this point in dealing with parent/child themes if you need a reason to take my advice on this.

How frameworks work

Confused yet? Let me break this process down for you and explain how it should work.

  • Frameworks come packaged within a single folder.
  • Developers drop the framework folder into a new parent theme and load the framework.
  • Users create a child theme based on the parent theme to house their customizations, allowing both the framework and parent theme to be updated.

Here’s a diagram for reference:

Theme structure when using a framework, parent theme, and child theme

Users should only ever have to worry about creating a child theme. This will allow them to make modifications without losing them when the parent theme is updated. They shouldn’t have to worry about all the other stuff.

As you can see by now (I hope), the question of grandchild themes has been completely averted because theme developers shouldn’t be adding advanced functionality (that might need future updating) within child themes.

Doesn’t Hybrid break these rules?

The Hybrid parent theme doesn’t break the rules. A couple of the child themes? Definitely. If I could afford a time-traveling machine (and if they existed), I’d zip back a year or two and turn a couple of those child themes into parent themes instead. We all have to learn from our mistakes, and I can freely admit that I’ve taken the wrong route on occasion.

So, I’m going to give you a real-world example of everything I’ve been talking about and how it could’ve been avoided with one of my own themes.

Hybrid has a child theme called Hybrid News. This child theme has a few extra features that make it more advanced than its parent theme. One good example of a problem was when WordPress 3.0 launched with a new menu system (which I love). The Hybrid News child theme has an extra navigation menu that’s not present within its parent theme.

The problem: How do you upgrade the Hybrid News child theme to use the the new nav menu system for its extra menu?

You certainly can’t expect users to upgrade the child theme and lose all of their customizations. To solve this particular problem, I wrote a tutorial on making the switch to the new system. But, it was just a way to avoid the larger problem at hand.

The solution should’ve been: Make Hybrid News a parent theme. This would allow it to be upgraded and users to keep their customizations intact.

If you’re a theme developer with a lot of advanced child themes, you may be thinking that you’ve got this problem all figured out. You may have already come up with plenty of nifty solutions for avoiding these types of problems. But, no one can foresee what new things will come in later versions of WordPress to conflict with those solutions.

Introducing Hybrid Core: A theme framework

Last year, I mentioned that I’d release Hybrid Core to the public for download. Unfortunately, that release never came out. I wanted some more time to perfect it, which turned out to be around a year worth of extra time.

Hybrid Core will be a theme development framework for use by other theme developers. What this means is that any theme developer will be able to download this and build parent themes with an awesome framework behind them. Yes, I’m essentially giving you the keys to the Theme Hybrid kingdom.

Hybrid Core is currently packaged within my Hybrid parent theme. It is used to handle the “logic” behind how the theme runs. Theme developers will be able to load this framework and build themes using the set of conventions provided by the framework. All of the HTML, CSS, and extra functionality will be left up to you.

In the next month or two, I’ll be putting the finishing touches on this. I’m still moving some stuff around that’s specific to the Hybrid parent theme and getting it out of the way.

It’d be awesome to see many great themes built off this framework. It’s a project that I started building in June 2008, so a lot of work and testing have been put into it. The next theme I build will be a parent theme based off it, so you’ll have a good, working example of how to use the framework.

Just in case you were wondering if building a "grandchild" theme is actually possible, the answer is no, at least not by default. And, I hope to never see the day it happens.