What are custom taxonomies in WordPress?

June 08th, 2009 – 32 Comments

In WordPress, content can be grouped using categories and tags by default. WordPress calls these groups taxonomies. When you are serious about your content and have a lot of it, it will pay off to create other groups as well. By creating these custom taxonomies, you are basically making your life as a content writer easier, and, even more important, you structure your website to your best effort for your visitor. Relevant content will be easier to locate and related content will be easier to find. This article will dive a bit deeper in the use of custom taxonomies.

Hierarchical versus non-hierarchical

WordPress, with version 2.3, introduced the concept of Tags. As described by Wikipedia, a tag is “a non-hierarchical keyword or term assigned to a piece of information”. This meant WordPress had a hierarchical way of classifying information (categories), and a non-hierarchical way of classifying information. As far back as in 2006 (!), people were discussing the fact that tags are not categories.

The issue is that WordPress calls them both “taxonomies”, when they’re actually not. They’re not, because the word taxonomy, as described in another Wikipedia page, assumes a hierarchy of sorts. With version 2.8, WordPress introduced (or actually gave more easy access to the already available backend for) custom taxonomies.

These custom taxonomies can be either non-hierarchical (eg. “tag” like) or hierarchical (eg. “category” like), but for now only the non-hierarchical taxonomies benefit from the smooth integration. These taxonomies are more “real” taxonomies though, as they add a level of hierarchy to the tag structure.

Let me give you an example: you could have a People and a Places taxonomy. Now, when you write a new post, you decide to add a keyword in the People taxonomy. By doing that, you’re saying that it’s a keyword (or tag, if you want) of the type People, so it is hierarchical in a way. But it also makes the keyword that much more informative, as it adds another layer of information.

Back in 2009, Roy Huiskes made this visual for us by making a graphical explanation of the subject:

custom taxonomies

Fun fact: That People taxonomy section would include some more branches nowadays.

You can imagine using this for locations or employees on a company site, writers on a book site, destinations on a travel site, etcetera. It groups items in a convenient way, both for maintenance and your visitor.

Custom taxonomies in WordPress

In WordPress, you can add custom taxonomies with plugins like , but it’s not that hard to do this manually as well. To register a taxonomy, you use the register_taxonomy() function. Most WordPress developers have probably used this one time or another, right?

WordPress.org gives a nice example of how to approach this for a People taxonomy:

function people_init() {
	// create a new taxonomy
	register_taxonomy(
		'people',
		'post',
		array(
			'label' => __( 'People' ),
			'rewrite' => array( 'slug' => 'person' ),
			'capabilities' => array(
				'assign_terms' => 'edit_guides',
				'edit_terms' => 'publish_guides'
			)
		)
	);
}
add_action( 'init', 'people_init' );

This adds a meta box to your WordPress post Edit screens, that looks like the Tag box, and works in the same way. I’m not a fan of tag clouds, but yes, you can even create a cloud for your new taxonomy. For a more in-dept explanation, check this post by wpmudev.org (2016).

These custom taxonomies can be public and private, which also makes them extremely useful for internal grouping of elements as well. I can imagine VIP users being grouped, social influencers, you name it.

Note: (Custom) Taxonomies and Gutenberg

As Matt Cromwell describes, “Gutenberg is the future of content in WordPress. It will deliver the elegance of Medium but with far more power and flexibility of layouts and content types”. But Gutenberg is in development and 99% of WordPress users probably won’t see any of it until it’s finished.

However, just last week, my colleague Tim added an issue to the WordPress/Gutenberg Github repo: Gutenberg shows private taxonomies in category and tag lists. Just dropping this here as a note, as I am sure this will be resolved before Gutenberg is released to the public. But if you are test-driving Gutenberg on a live site, and you are using custom taxonomies somewhere on that site, it might be something to check. Just to be sure!

How are you using custom taxonomies?

So, in conclusion, custom taxonomies can be very useful. If you have loads of content and want to create order in the chaos, for both yourself and your users, you should really use them!

That leaves me with two questions: Are you using custom taxonomies and if yes, how did you add these to your site? Looking forward to your answers in the comments!


32 Responses to What are custom taxonomies in WordPress?

  1. Charles Clarkson
    By Charles Clarkson on 21 September, 2009

    Any idea on which hook would I use to remove custom tags when a post is deleted?

    Or a housecleaning routine to clear out unassociated custom tags?

  2. Fuji
    By Fuji on 20 August, 2009

    Hi Joost,

    Can the taxonomies also be found with a search? And will they also export when exporting WP posts?

    BR
    Fuji

  3. Michel H
    By Michel H on 1 July, 2009

    I’m very visually inclined, but it still took me a while before I grasped the concept of custom taxonomies. At least, I think I understand. I HOPE I understand.

    Say I’m going to blog about certain products (which is true, and led me to the subject of custom taxonomies). Let’s take cars for example. Then an example of a custom, hierarchic taxonomy would be to create a ‘body type’ taxonomy, with tags like ‘convertible’, ‘sedan’, ‘hatchback’ and ‘coupe’. Is that right? But then, your bit about making sure the URL rewrites work, confuses me again. Would that mean that blogURL/bodytype/hatchback would lead to a list of articles about hatchbacks?

    If that’s what it is, I think I’m half way where I want to be. What I would like is to put the products (cars for this example) in the WordPress database, and set the custom taxonomies for every car, so that I can just select a car when posting about it, and the correct information/tags will show up. But that would require more than just this plugin to handle the custom taxonomies itself, right?

  4. seo company
    By seo company on 19 June, 2009

    Like everything in life, wordpress taxonomy can organize the data in a vertical pattern and in an horizontal way too, where there is no ascending or descending order.

  5. Oren
    By Oren on 16 June, 2009

    Why are you linking wikipedia links to non-informative terms such as “As described by Wikipedia” and “as described in another Wikipedia page”. Is there any particular reason for this (SEO stuff) or not?

    • Joost de Valk
      By Joost de Valk on 16 June, 2009

      No :)

      • Oren
        By Oren on 17 June, 2009

        Oh cool :) I thought that you guru SEO guys spend hours making every post perfect, well this myth is dead now.

  6. Adam
    By Adam on 16 June, 2009

    Awesome plugin! One bug: quick edit of items doesnt seem to work- I get an ‘edit failed’ error every time. Thanks for the awesome plugin!
    -Adam

    • Joost de Valk
      By Joost de Valk on 16 June, 2009

      That’s a bug in “core” then :)

  7. meatbagwtf
    By meatbagwtf on 15 June, 2009

    Very cool post. To me, it’s amazing that tags and categories have been confused and abused for so long. The wordpress.com help pages, back in 06 if I recall correctly, did little to relieve this confusion. The solution I undertook at the time was to use tags and categories more-or-less interchangeably, but to limit the use to one or the other as much as possible (to reduce duplicate content) and to rename “tags” or “categories” according to the desired taxonomical top level designator :) (like “posts”, or “mesothelioma”, or something). Kind of goofy, but imagine it’s 2006 and you have stakeholders asking “ok, we have categories, what about tags? Don’t we need those too?”

    Hmmm, the old Wikipedia page on folksonomy seems to have a bit to say about hierarchies and tags: http://en.wikipedia.org/wiki/Talk:Folksonomy/old

  8. Engelium
    By Engelium on 13 June, 2009

    Hi

    I’m very interested in custom taxonomies but in my tests this plugin didn’t work as expected

    In options it’s all right but:

    – If I click on the link for a taxonomy (at the end of the post) I get a “Page not found” message

    – seems there is not a feed for custom taxonomies

    Tank

    • Charles Clarkson
      By Charles Clarkson on 21 September, 2009

      Try updating your Permalinks (Settings -> Permalink). Just go to the page and click Save Changes after installing the Simple Taxonomies. THat helped me solve a similar problem.

  9. Shane
    By Shane on 12 June, 2009

    Any plans to be able to move taxonomies from one group to another? This would be especially useful for sites that have hundreds of post-tags, but would like to break it up in places, people, etc.

  10. Rob Blatt
    By Rob Blatt on 11 June, 2009

    Love the plugin, but I’m looking for a way to create a page with all of the terms of a taxonomy. For instance, on my site I have a taxonomy for “bands played” and I’m looking to create a page that displays all of the tags created. Am I missing this?

  11. Steffen
    By Steffen on 10 June, 2009

    Great! Future starts now!
    Long time hoped of this http://nerdlife.net/custom-taxonomies/, how you are here. thanx

  12. David Bell
    By David Bell on 9 June, 2009

    Hey Joost, another interesting plug-in, I’m definitely going to be using this one. Just what I need for one of my client sites. Thanks very much.

  13. Piet
    By Piet on 9 June, 2009

    Forgive me my ignorance, but now I know what custom taxonomies are, but I (still) don’t understand what their function is and how to use them…
    Is that easy to explain or do you know (of) a good source for that answer?

    btw congrats on the cooperation between you and Brian!

    • Joost de Valk
      By Joost de Valk on 9 June, 2009

      Best way is to try them… Check out my plugin and give them a go!

  14. Seotaal
    By Seotaal on 9 June, 2009

    Normally an taxonomy is a classification based on observations. A classification is based on a concept.

    In this context i don’t find the denomination taxonomy correct, but I understand what wordpress means. In spite of tags not being hierarchical, a cetain hierarchy is still possible. So a great addon to the WordPress tags system :).

    • Joost de Valk
      By Joost de Valk on 9 June, 2009

      Hehe well the choice of terms for things like these is horrible to do well, I guess…

  15. Damon Gudaitis
    By Damon Gudaitis on 9 June, 2009

    Wow and thank you. This was on my to-do list, so you just saved me some time and probably did a better job too.

    Also, your site isn’t displaying properly in Firefox on my Mac. The “Speaking” list item is on a new line displaying on the left of the page under the “WordPress” section and all of the attached formatting is throwing everything off. Contact me if you need help reproducing the error

    • Joost de Valk
      By Joost de Valk on 9 June, 2009

      As said in email, get a proper nofollow highlighter that uses outline instead of border :)

  16. Navin Poeran
    By Navin Poeran on 9 June, 2009

    Very nice article, just the other I was reading a terrific post about this at SEObook.

    For those interested, should check it out for sure:
    http://www.seobook.com/search-taxonomy-getting-inside-mind-searcher

  17. Carl Hancock
    By Carl Hancock on 9 June, 2009

    How about a version that supports custom hierarchical taxonomies?

    • Joost de Valk
      By Joost de Valk on 9 June, 2009

      I’ve absolutely thought about it, and am still thinking about it. Wanted to get this out, but might add that in the future.


Check out our must read articles about Analytics