A Basic Explanation of WordPress Taxonomies

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.”

custom-taxonomies-wordpress-diagram

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.

Additional Reading

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:

Custom Taxonomies in WordPress 2.8

Using Custom Taxonomies to Create a Movie Database

Also visit Pop Critics to see how they are using custom taxonomies.

All Comments

Loading Facebook Comments ...

Comments

  1. MacBoy says

    Good explanation. This is a tough subject to understand and explain.

    You’re right about Justin Tadlock. He knows a lot and he has an easy way of explaining the tough things to normal people!

    :-)

  2. says

    MacBoy, Yeah, JT knows his stuff. Glad you found this helpful! The more I worked on trying to simplify this topic the harder it seemed to do. Hopefully if anyone still doesn’t understand they’ll ask questions (here or on Justin’s site).

    • Paul says

      I read JT’s stuff before I found this, and I’ve read other stuff. I understood that it was a way to cl.assify data, but no one that I read really explained what the benifit was. I was kind of getting a glimpse but not really putting it all togetner. It’s funny how no one explains the basic concept of a lot of things in computer technology. They just assume you should understand. It’s really simple, but no one wants to give the basic simple explanation. Finally I understand the purpose of custom taxonomies.

    • Paul says

      Somehow I’m not surprised. I use Roots wordpress theme for everything any more. On the Roots page he has several featured plugins. Sribu wrote more than one of them. It’s funny how certain people stand out.

  3. says

    Grumpy,

    Great find! I haven’t had a chance to download and play with that plugin yet but looks like it has huge potential.

    Nice looking site you have there too!

  4. Annabel says

    Another super-helpful post, Scott, you've given me a good start in how to think about organizing the content on my website (my very first!).

  5. Cliff says

    Thanks. I found this simple enough to give me an understanding, not only of taxonomy, but custom taxonomy as well. Keep up the good work… and I've just subscribed to your RSS feed.

  6. says

    Cliff – Glad you found it helpful! If you happen to be in the area or want to come to Dallas I'll be giving an entire lecture on Categories, Tags and Taxonomies at Opencamp http://openca.mp at the end of August.

  7. osu says

    Hi Scott,

    Thanks for this article, it’s an interesting read. I have a question though (and forgive me if it’s a stupid one, this is a new area of WP for me!): Couldn’t you just organise your content using categories and sub-categories to do the same thing?

    I understand the benefit of custom posts as you can create nicely formatted custom fields to attach extra details to your custom post. But taxonomies have me a bit stumped – particularly as it sounds like you’re saying a subcategory is a term of the taxonomy ‘Category’ and a tag would be a term of the taxonomy ‘Tag’ in WP early on in the article, but then you talk about custom taxonomies as being like a term of a term of a term (assuming I’ve understood correctly):

    Category (taxonomy)
    -Category called Movies (term)
    –Genre (custom taxonomy)
    —Action, Romance, Porno etc. (custom taxonomy terms?)
    –Actors (custom taxonomy)
    —Brad Pitt, Robert Redford, Dirk Diggler etc. (custom taxonomy terms?)

    I suspect I’m thinking too much in terms of organising content hierarchically while you’re probably talking in terms of grouping together data, so I thought I’d ask!
    Thanks

    osu

    ps. the name field in this comment form seems to float separately from the rest of the fields like Email and Website on my Mac using Firefox 3.6.9 0

  8. says

    OSU –
    You definitely “can” organize your content using categories and sub-categories but it’s not the most scaleable approach and if your content becomes expansive enough it can become very cumbersome. You also may loose some cross-relational opportunities within your content. Looking at your second paragraph I think you might be over-thinking it a bit (and I probably need to re-write some sections to make it clearer).

    However your example is right on. Action, Romance, .. are “terms” in the custom taxonomy “Genre”. “Brad Pitt” is a term in the custom taxonomy “Actors.”

    It’s easy to want to make your content very hierarchical (and to some of extent that can be appropriate) but I’ve found the flatter I keep my content and use a combination of categories & custom taxonomies, it frees me up to organize my content in a number of different ways (more flexible) without sacrificing flexibility or easy of navigation.

    Think of your categories as the “Table of Contents” for your site and Taxonomies as the index.

    For what it’s worth I’m going to be writing much more about his in the very near future so stay tuned. Lot’s to come.

    • Joel says

      Thanks for the informative article Scott. I’ve been creating websites with WordPress for about 2 years but never really used anything other than Pages. Recently, though I’ve started to experiment using Posts and last week played around with Custom Post Types and Custom Taxonomies. Needless to say, I’m a bit confused as to how they all work together.

      I’m working on a site for a pool and spa parts manufacturer and thought it would be a perfect opportunity to jump in using these new (to me at least) features, but I’m not sure what route to take setting up the Post Types and Taxonomies. Hopefully you can give me a little advice.

      They have 3 main lines of products (Pool, Spa, Hot Tub). Within these 3 main lines they have categories of products such as Pumps, Filters, and Drains. Furthermore, within say Filters, it can be further broken down into Above Ground and In-Ground. Filters can be found under all of the three main lines. My main question is, what would be the best way to set this up?

      Should I have 3 Custom Post Types, one each for Pool, Spa, and Hot Tub? Do I create a custom taxonomy for Pumps, Filters, and Drains with Above-Ground and In-Ground as terms?

      Pumps (custom taxonomy)
      Above Ground (term)
      In-Ground (term)

      Filter (custom taxonomy)
      Above Ground (term)
      In-Ground (term)

      Thanks for any light you can shed.

      • says

        Joel, custom taxonomies could work but are you planning to apply them at the individual product level?
        For example, you could have a pool filter as well as a hot tub filter and if you didn’t set it up right they might not be sufficiently differentiated.

        You might make “Pool, Spa, Hot Tub” as the WP categories, “Product Type” as the taxonomy (terms: pump, filter, drain) and another taxonomy as “Ground Level” (terms, Above Ground, Below Ground).

        That is my initial thought anyway.

        Alternatively, you could make them all taxonomies . Taxonomy: TubType. Terms: Pool, Spa, Hot Tub

        To make it easier to lay things out you could have the Tub Type as both a category and custom taxonomy.

        Make sense?

  9. says

    One useful way you could try to use taxonomies alongside categories is where there are two differrent dimensions of data eg the movie categories you have above AND the language the movies are in.

    A taxonomies schema and navigation could be provided for one and categories used for the other.

  10. Joshua Iniyan says

    Thank You Scott,

    Good introduction to Taxonomy.

    I’m new to this will u refer any best plugin to manage custom Post types & Taxonomy

    BTW Your site looking simply great…which font you used?

  11. says

    I’ve been researching this for a few days now because I’m trying to create a professional learning portfolio (portfolio.EditorialPartnersLLC.com), and I’m thinking custom taxonomies will help me with organizing it. Your explanation about using categories and taxonomies together as different levels *really* helped, especially displaying it in the matrix.

    My question is whether the “terms” you have in the matrix could be another level–that is, custom post types? I’m struggling to understand the relationship between custom taxonomies and custom post types. For instance, in a matrix I’d create like the one you have above, the “terms” would become four different post types–called for my purposes “learn,” “do,” “reflect,” and “teach.”

    • says

      LeahGrrl, Sorry for the delay, somehow your comment slipped through the cracks.

      To answer your question, I woud use custom taxonomies to compliment your custom post types. Taxonomies are just collections of the taxonomies and the terms within them (kind of like tags but more specific and granular). Custom post types have all the features and functionality of regular posts but are usually augmented in some way like having specific taxonomies associated with them.

      In your case you might create a custom post type for “learn” and associate the taxonomies with that are appropriate. Make sense?

Trackbacks