The complete guide on what a taxonomy is, how to create custom taxonomies in WordPress the easy way, and how to display custom taxonomy
In WordPress, content can be grouped using categories and tags by default. WordPress calls these groups taxonomies. Creating other groups will pay off when you are serious about your content and have a lot of it. By creating these custom taxonomies, you’re making your life as a content writer easier. More importantly, you’ll structure your website to your best effort for your visitors. They’ll be able to locate content that’s relevant to them and find related content more easily. This article will dive into the use of custom taxonomies.
Hierarchical versus non-hierarchical
WordPress introduced the concept of tags in version 2.3. As Wikipedia describes, a tag is a non-hierarchical keyword or term assigned to a piece of information.’ This means WordPress has had a hierarchical way of classifying information (categories), and a non-hierarchical way of organizing information (tags) since version 2.3. Back in 2006 (!), people discussed that tags are not categories. The problem is that WordPress calls them both ‘taxonomies,’ but that’s not entirely correct. The word taxonomy assumes a hierarchy, as explained on another Wikipedia page.
With version 2.8, WordPress introduced custom taxonomy. Or it allowed more accessible 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 taxonomy, though, as they add a 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. But it also makes the keyword much more informative, adding another layer of information.
Some years ago, Roy Huiskes made this visual for us by making a graphical explanation of the subject:
Fun fact: The People taxonomy section in the image above would include 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 for your visitors.
Custom taxonomies in WordPress
Adding custom taxonomies in WordPress isn’t that hard. You can use the register_taxonomy() function to register a taxonomy manually. Most WordPress developers have probably used this at one time or another, right?
WordPress.org has an example of how to approach this for a People taxonomy:
This code adds a meta box to your WordPress post edit screens that look 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 shadow for your new taxonomy. For a more in-depth explanation, check this post by wpmudev.org (2016).
These custom taxonomy can be public and private, making them extremely useful for the internal grouping of elements. I can imagine grouping VIP users, 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 currently in development, and 99% of WordPress users probably won’t see any of it until it’s finished.
However, last week, my colleague Tim added an issue to the WordPress/Gutenberg Github repo: Gutenberg shows personal taxonomies in Category and Tag lists. Just dropping this here as a note, as I am sure the development team fixes this before releasing Gutenberg to the public. But if you are test-driving Gutenberg on a live site and using custom taxonomies somewhere on that site, it could be something to check. 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 orders for yourself and your users, you could use them.
That leaves me with two questions: Are you using custom taxonomies, and if yes, how did you add these to your site? I’m looking forward to your answers in the comments!
Create WP Taxonomies with a Plugin – Simple Solution
The first thing you need to do is install and activate the Custom Post Type UI plugin.
In this tutorial, we have created a custom post type and named it “Books”. So make sure you create a custom post type before creating taxonomies. Next, go to the CPT UI » Add/Edit Taxonomy menu item in the WordPress admin to create your first taxonomy. On this screen, you need to do the following:
- Create your taxonomy slug (this will be included in your URL)
- Build plural labels
- Add a single label
- Autofill labels following the WordPress taxonomies guide
Your first step is to create a slug for classification. This slug is for URL and WordPress searches.
This can only contain letters and numbers and is automatically converted to lowercase.
Next, enter plural and singular names for your WordPress custom taxonomy following the taxonomies guide.
You can optionally click the “Fill in other tags based on selected tags” link. When you do this, the plugin will automatically fill in the rest of the label fields.
WordPress taxonomies guide: Now scroll down to the Additional Tabs section
This area allows you to describe the post type.
These tags will be used in your WordPress dashboard when editing and managing content for specific custom taxonomies.
Next, we have the setup options. In this area, you can set different properties for each category you create. Each option has a description detailing what it does.
In the screenshot above, you can see that we have chosen to layer this taxonomy. This means that our “topic” taxonomy can have subtopics. For example, a fiction topic might contain subtopics like Fantasy, Thriller, Mystery, etc.
There are many other settings in the WordPress dashboard below the screen, but you can leave them as-is for this tutorial.
You can save your custom taxonomy by clicking the Add Taxonomy button below. After that, edit the post type associated with that category in the WordPress content editor to use it.