Over the last week or so I’ve started playing intensely with custom taxonomies in WordPress, and the geek in me is in love with the possibilities. Now, before you go running off thinking this is only hardcore “geek stuff” let me explain what taxonomies are, why they are important and provide a basic example of how to use them. I’ll expand on all of this is a future series of posts but I wanted to start with the basics since it will give me something to refer back to and will sent the groundwork for understanding taxonomies.
For ease of explanation, let’s pretend we have a website that is about entertainment. (Disclaimer: I’m using the example of entertainment because I want to point you to a live site with info about entertainment by Justin Tadlock, who has written a couple of very good articles on WordPress Taxonomies, but more on that later).
What is a Taxonomy in WordPress?
By default, WordPress comes with 3 taxonomies, post tag, categories, link categories. Essentially, a taxonomy is a way of classifying data. Typically a taxonomy will have a set of characteristics that is unique to it. To be obvious, if a taxonomy had the same characteristics as another data type, it wouldn’t be a different taxonomy! Example of those characteristics follow:
- Post Tag: acts like a label, attached to a post.
- Category: acts like a “bucket” in which we put posts, are often hierarchical. Posts can live in multiple categories.
- Link Category: acts like a label, attached to a link.
Each tag or category you create is a “term” within that taxonomy. For example, if you create a category “Movies” (in our site about entertainment), “Movies” becomes a term within the category taxonomy.
Now, there are different types of movies so this is where our custom taxonomies come in. If we created a custom taxonomy “Genre”, then we could add “Action” which becomes a term in the “Genre” taxonomy. So we are classifying our movies by “Genre.”
Why Use Custom Taxonomies in WordPress?
In a nutshell, we use custom taxonomies to make it easier to organize our content. While you could attach an appropriate tag or set of tags to a post you aren’t really separating things out as much as you could. By separating things out in a more granular way, and giving our selves a way to classify data, we have more opportunity to display content and create relationships in various and logical ways. Let’s go back to our entertainment site for an example…
How To Use Custom Taxonomies in WordPress
To begin with, we’re likely to have our highest order of organization as our categories. Let’s assume we have Movies, Television, Books and Celebrity News as our categories.
If we think about the characteristics of movies, then assume we have created four custom taxonomies that relate to movies: Genre, Director, Actors and Studio.
I can now enter terms into my “Genre” taxonomy such as “Action” or “Romance” (which of course become terms in the Genre taxonomy).
Understanding why this is important: We can now create a list of Movies in the “Action” genre as well as display the genre of a movie on the movie’s individual page (which also serves as a link to all movies classified as “Action”). If we had just used tags, there would be a lot of other stuff to filter through and display, not just “Action” next to the “Genre:” label which corresponds to the “Genre” taxonomy. (Make sense?). For clarity, if we just used tags how would we show what “genre” it’s in without showing all of the other tags associated with the movie? We couldn’t (effectively) since the “Action” would be just one of many tags associated with the move and we would have no way of distinguishing “genre” from “actor” since they would all be classified as “tags.” Get it!!!
One downfall, as far as I know there is no way to cross-reference custom taxonomies (Actors with Genre e.g. show a list of movies with actor “Bruce Willis” AND genre “Action”). I expect this will someday get remedied as people use custom taxonomies more.
Below are two posts that you should read by Justin Tadlock about custom taxonomies, they are very good and give great examples and explanations of custom taxonomies. To be honest, he knows far more about this than I do and while I’ve never met the man, he’s one of those guys that has probably forgotten more about WordPress than most of us will ever know. Quite frankly, I’m only adding my $.02 because I thought a few of the concepts and some of the terms needed to be a little more “simply” explained, particularly if you are not a pretty technical WordPress user or don’t live and breath this stuff.
In order, read:
Also visit Pop Critics to see how they are using custom taxonomies.