What are custom taxonomies in WordPress?

by | Sep 25, 2017 | WordPress | 0 comments

With version 2.8, WordPress introduced custom taxonomies. Or actually, allowed easier access to the already available backend for custom taxonomies. These custom taxonomies can be either non-hierarchical (e.g. ‘tag’-like) or hierarchical (e.g. ‘category’-like). But for now, only the non-hierarchical taxonomies benefit from the smooth integration. These are more like actual taxonomies though, as they add a kind of hierarchy to the tag structure.

Let me give you an example: you could have a ‘People’ and a ‘Places’ taxonomy. Say, you write a new post and 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.

Some years ago, Roy Huiskes made this visual for us by making a graphical explanation of the subject:

custom taxonomies

Fun fact: That People taxonomy section in the image above would include some more branches nowadays.

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

Custom taxonomies in WordPress

Adding custom taxonomies in WordPress isn’t that hard. To manually register a taxonomy, you can use the register_taxonomy() function. Most WordPress developers have probably used this one time or another, right?

WordPress.org has an 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 piece of code adds a meta box to your WordPress post edit screens, that looks like the tag box. It even works in the same way. I’m not a fan of tag clouds, but yes, in theory, you could even create a cloud for your new taxonomy. For a more in-depth 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 grouping VIP users, social influencers; you name it.

https://yoast.com/wordpress-custom-taxonomies/

On – 28 Aug, 2017 By Michiel Heijmans

If All Else Fails

If none of the solutions above helped, help is available 24/7. All you have to do is get in touch with us through our WordPress emergency fix.