One of the things I’ve always liked and disliked equally in WordPress is its templating system. I love how easy it is to just create templates for all sorts of things. I dislike the hierarchy.
Don’t get me wrong — the hierarchy works for most sites.
But, when it comes to highly-customized sites with loads of content and many pages and archives that need different functionality, things can get a bit messy and unorganized.
The new template hierarchy
In Hybrid version 0.7, there’ll be a slightly different logic behind the templating system. I neither wanted to go completely overboard nor confuse people too much, so much of it is based off the old template hierarchy.
This isn’t quite the future I have in mind for a complete reworking of the WordPress template hierarchy, but I believe it’s a step in the right direction. And, that step is about adding structure. There are some things that need to change internally in WordPress for me to have the system I really want.
You can also take a look at the default WordPress template hierarchy and compare the two.
A good bit of it retains the default WordPress hierarchy, but a few things have been reworked. Here’s some of the major changes:
- All taxonomies (including tags and categories) use the same template naming system.
- Got rid of
single.phpfor singular posts in preparation of custom post types, so all singular views will be in line with one another.
- Singular posts will now recognize custom post templates.
- All attachment templates begin with
attachment, so they’ll be recognizable as attachment templates.
- Author templates begin with
useras opposed to
authorsince all registered users are given an “archive” page on the site whether they’ve written posts or not.
- Date and time archives are broken down into the specific date/time rather than just using the
Why the change?
For those of you that run a regular blog, you could probably get away with only having an
index.php template. But, in my experience working on some larger-scale projects (and I’m sure others will agree), there’s often a need for a lot of customization when specific types of pages are shown.
Rather than having to recode the same functions over and over for those projects, Hybrid will make that job easier by breaking down the templating system based on context. So, if you ever need a new template for a specific page of the site, all you have to do is build it rather than jumping through hoops just to use it.
There’s still some work to be done to have a better organizational structure, but I’ll save those ideas for another day.
What do you think?
This is something I’ve been discussing on and off for a while in the Ideas forum, but I wanted to open this up to a larger audience here on the blog.
Do you like this new hierarchy compared to the old one? What would you like to see changed?