WordPress Custom Taxonomy 101: What They Are + How to Use Them
WordPress custom taxonomies, along with custom post types and custom fields, are a big part of what makes WordPress a flexible content management system, rather than sticking to its blogging roots.
In this post, I’ll dig into everything about custom taxonomies on WordPress. You’ll learn:
- What a custom taxonomy is and why it’s useful
- When to use taxonomies vs custom post types/fields
- How to create custom WordPress taxonomies
- How to create a custom taxonomy archive page to display content from that taxonomy
What Are WordPress Custom Taxonomies? In More Detail
In the broadest terms, a taxonomy is a way to group items together. The benefits are that:
- You can organize your content by keeping it grouped together.
- Your visitors can use your taxonomies to find content that they’re interested in.
- You can use taxonomies to control how your site displays information, especially if you create custom taxonomy archive pages (which I’ll show you how to do).
WordPress already comes with two taxonomies for your blog posts:
But with custom taxonomies, you can create your own taxonomies that apply to any post type.
For example, if you post about movies, you could create a taxonomy to hold a movie’s genre or director.
Hierarchical vs Non-Hierarchical Taxonomies
WordPress lets you create two types of taxonomies:
- Non-Hierarchical (Flat)
By default, WordPress includes one of each type of taxonomy:
- Categories are hierarchical
- Tags are non-hierarchical (flat)
A hierarchical taxonomy can include different “levels”. For example, you could have a “WordPress” taxonomy and then a “Plugins” sub-taxonomy within the parent “WordPress” category. Again, the easiest way to understand this is to look at regular categories for your WordPress blog posts.
A non-hierarchical taxonomy does not include multiple levels – it’s just flat. You could have one taxonomy for “WordPress” and another for “Plugins”, but the two taxonomies wouldn’t be connected in any way. Again, the easiest way to understand this one is to look at regular tags for your WordPress blog posts.
Custom Taxonomies vs Custom Fields/Post Types
Both custom taxonomies and custom fields/post types help you store more information about a post, so when should you use each?
Sometimes the answer is obvious, but you’ll also have situations where there might be some overlap and it could go either way.
For example, let’s say you have an “Apartment” custom post type and you want to associate those apartments with specific cities. You have two options:
- Add a “City” custom relationship field that links to a “City” custom post type
- Add a “City” taxonomy
Which is better?
Well, I don’t think there’s a single answer, because it depends on how you’re planning to use the “City” information.
If you just want to use the “City” information to group together the “Apartment” post type and help visitors filter “Apartments”, then you should probably use a custom taxonomy. Again, the primary purpose of taxonomies is for grouping and filtering content. So if that’s all you need, use a taxonomy.
On the other hand, if you also want to create standalone pages for each city that include detailed information about that city, you might be better off adding each “City” as a separate custom post type and linking “Cities” with “Apartments” via a relationship field (which you can add with plugins like Toolset, Advanced Custom Fields, or Meta Box).
In this second scenario, each “City” is not just a tool for grouping and filtering, it’s also its own standalone entity.
Another example might be a “Book” custom post type that you want to associate with “Authors”:
- If the primary purpose of the author information is just to group books and help visitors filter them, then you probably want a custom taxonomy.
- If you want each author to also be its standalone entity, then you probably want to create an “Author” custom post type and link it to the “Book” post type using relationship fields.
How to Create Custom Taxonomies With Toolset
While you can register your own custom taxonomy using code, there are several popular plugins that make the process much simpler.
Good options are:
- Toolset (specifically, the Types component)
- Custom Post Type UI
- Meta Box, with the free MB Custom Taxonomy add-on
We like Toolset here at WPLift because it lets you do more than just create custom taxonomies – it also helps you use those taxonomies. For that reason, I’m going to use Toolset for this tutorial, though the basic process will be the same for all of those plugins (because they’re essentially just translating the manual code method into a user-friendly interface).
First, give it a name. For this example, I’ll create a special “Genre” taxonomy to be applied to my blog posts (let’s say I write a lot of movie reviews).
Then, choose between a Hierarchical or Flat taxonomy.
Finally, choose which post type(s) to associate with your taxonomy. For example, to make your custom taxonomy active on blog posts, you’d check the box for Posts:
If you want more control, you can expand the Options settings to control settings like your taxonomy’s URL structure:
And that’s it! Once you click Save Taxonomy, you’ll be able to use your taxonomy from the associated post types just like you would built-in categories and tags:
You’ll also get an area dedicated to that taxonomy under your post type menu. For example, Posts → Genres:
Again, I used Toolset Types for this example, but the process will be almost identical for all of the other plugins that I mentioned.
How to Create Custom Taxonomy Archive Pages With Elementor Pro
A taxonomy archive page is a page that lists all the content items that have that taxonomy. For example, if you click on a category on your blog, your site will display the category archive page that lists all of the blog posts in that category.
By default, WordPress will use your regular theme archive template to display your custom taxonomy items. However, you can also create your own custom taxonomy archive pages to display information in a custom way.
With Elementor Pro, you’ll be able to design your archive page layout using a visual, drag-and-drop page builder interface.
- Select Archive for the template type
- Give your template a name to help you remember it
From there, you can either choose one of the pre-built archive templates or design your own from scratch:
To preview your design with content from your custom taxonomy:
- Click on the gear icon in the bottom-left corner
- Open the Preview Settings
- Select your custom taxonomy
When you’re finished with your taxonomy archive design, click to Publish it and use the Include rules to target your custom taxonomy:
Now, when people browse the archive page for one of your custom taxonomy items, they’ll see the custom archive template that you created.
You can also use Elementor Theme Builder to create custom single post templates based on your custom taxonomies, which gives you another way to create custom designs.
Get Started With Custom WordPress Taxonomies Today
Taxonomies are an important tool to help you group content on your WordPress site.
Do you have any questions about working with custom taxonomies on WordPress? Leave a comment and we’ll try to help!