Are you looking for an easy way to create custom taxonomies in WordPress? Every WordPress website comes with two taxonomies: categories and tags. But if you want to further organize the content on your website, this easy guide will help you create, display and filter by a custom WordPress taxonomy.
WordPress taxonomies have made structuring and grouping content effortless for most of us, but there can be instances where having custom taxonomies can help structure the content more effectively.
For example, if you have a niche website, such as a Book review site, you can have ‘Book Types’ as a taxonomy for filtering content. You can even add custom sub-taxonomies such as Classics, Fantasy, or thrillers’ to further structure the content on your book review site.
In this guide, you'll learn:
- What are custom taxonomies?
- How to create custom taxonomies with new custom post types.
- How to create custom taxonomy in WordPress for existing post types.
- Creating hierarchical and non-hierarchical taxonomies.
- How to display custom taxonomies on the website.
- How to allow website visitors to filter and sort content by taxonomy filter.
By the end of this tutorial, you’ll be able to create custom taxonomies and custom post types and display them to visitors like this:
If you are a beginner WordPress user, custom taxonomies can be a little confusing. Let’s start with that.
What are custom WordPress taxonomies?
A WordPress taxonomy is a way to organize and structure the content on your website. Just like how taxonomy (as a field of study) has helped biologists classify and group biological organisms, WordPress taxonomy function helps organize the content on a WordPress site.
By default, every WordPress site has two taxonomies:
You can use them to group or structure blog posts and pages on your website fairly quickly.
While these might be sufficient to manage and structure content type on a standard website, they can be pretty limiting if you wish to further categorize and diversify your website content.
For example, if you have a movie review website, you can add ‘Genre’ as a custom taxonomy so your visitors can directly check your reviews of the movies in that particular genre. Based on your website's content, these genres can be horror, action, drama, thriller, adventure, etc.
Custom taxonomies can be hierarchical too. This means your custom taxonomy terms can have sub-categories to further define the website’s content type structure. The movie review website example can have a category like ‘Action’, which can further have sub-categories like ‘Disaster Movies’, ‘Superhero Movies’, or ‘Spy Movies’. This is what the structure can look like:
- Action (Parent taxonomy)
- Disaster action movies (sub taxonomy)
- Superhero action movies (sub taxonomy)
- Thriller (Parent taxonomy)
- Crime thriller movies (sub taxonomy)
- Psychological thriller movies (sub taxonomy)
- Comedy (Parent taxonomy)
- Slapstick comedy (sub taxonomy)
- Parody comedy (sub taxonomy)
Now that we know what custom taxonomy means. Let’s see how you can create them.
Step 1: How to create custom taxonomy in WordPress
WordPress is quite flexible, and for creating custom taxonomies, you get a few alternatives. Broadly, here are the two ways to create custom WordPress taxonomies.
- Creating custom WordPress taxonomies with code (for developers)
- Creating custom WordPress taxonomies with a free plugin (for non-developers)
Let’s discuss both of these in more detail.
How to create custom taxonomy in WordPress via coding
This is for developers or someone who likes taking the technical approach to making WordPress customizations. You can code your way to creating custom taxonomies. To give you an idea, first you need to register the custom function
add_action in the functions.php file. Then create a new taxonomy with the
register_taxonomy function with relevant parameters and args.
Since this guide is focused on non-developers, we won’t be digging deep into this approach. Here's a free tuts+ guide on creating custom WordPress taxonomies using PHP, HTML, and CSS that you can check out.
How to create custom taxonomy in WordPress with a plugin (no-code way)
If you don’t want to take the code way, you can easily create custom WordPress taxonomies with a WordPress plugin.
There are many popular WordPress plugins for creating custom post types and taxonomies. For this tutorial, we’ll be using the free Easy Post Types and Fields plugin to create custom taxonomies.
We designed this plugin with an aim to make the process of creating custom post types and taxonomies more simplified. With the Easy Post Types and Fields plugin, you can do the same in minutes, and that too without touching a single line of code.
Setting up taxonomies with a plugin is better as it takes less time to set up, and it never leads to any coding-related issues. In addition to that, when you opt to go with the codeless route, it’s easier for someone else to understand the system and make future adjustments.
You can easily avoid such issues with the Easy Post Types and Fields plugin. So, let’s see how you can set it up.
Installing Easy Post Types and Fields plugin
To install the Easy Post Types and Fields plugin, follow these steps:
- Login to your WordPress admin dashboard and go to Plugins → Add New.
- Now search for ‘Easy Post Types and Fields’ in the search bar. Locate the plugin and make sure you see the author as ‘By Barn2’. If you can’t locate the plugin, you can download it from WordPress.org and upload it to your WordPress website.
- Once the plugin is installed, click on the Activate button.
After activating the plugin, you’ll be redirected to the setup wizard. If you wish to create custom post types, you can use this wizard. But if you wish to just create custom taxonomies, you can click on the Skip Setup Wizard link.
Creating custom taxonomies with Easy Post Types and Fields plugin
With the Easy Post Types and Fields Plugin, you can create custom taxonomies for existing post types (categories and tags). Or you can create custom post types alongside creating new custom taxonomies.
Let’s check out both of them one by one.
How to create custom taxonomies with a new custom post type
In this scenario, we'll create a new post type and custom taxonomies for the same.
For this, you can go with the setup wizard as it covers both parts: custom post types and custom taxonomies.
Alternatively, you can follow the steps below:
- Go to Post Types → Manage in your WordPress admin dashboard.
- Click on the Add New button to add a new Custom Post Type.
- Give your post a singular name as well as a plural name. For example, Movie (Singular) and Movies (plural). Click on the Next button.
- From the checkbox list, select the type of information you want the custom post type to have. Then, click on the Create button.
Your custom post type is now ready. Now you’ll find the links to add custom fields and taxonomies.
- To create a custom taxonomy, select the Add taxonomies button.
- You’ll be redirected to the custom taxonomies page. Click on the Add New button to add a new item.
- Give your taxonomy a singular name and a plural name.
- Click on the Add Taxonomy button.
After adding custom taxonomies, it will show up in the Manage Taxonomies page of the respective custom post type. Also, it will be listed as a taxonomy for the newly created post type and will be displayed on the backend like this:
How to create custom taxonomy in WordPress for existing post types
We know that WordPress has its own default post types: Categories and Tags. If you want to extend this and add custom taxonomies to existing post types, follow these steps:
- First, go to Post Types → Manage in your WordPress admin dashboard.
- Next, head over to Other Post Types by clicking on the tab. You will find this right next to the Easy Post Types tab.
- Now click on the Taxonomies button for the post type you want to update. Here I am adding a new taxonomy to Posts.
- Click on the Add New button and give it a singular and plural taxonomy name. The slug or the permalink will be autogenerated, but you can change it.
- Click on Add taxonomy button.
New custom taxonomy to existing post types is now successfully added. Now you can add individual terms for the taxonomies.
How to create hierarchical and non-hierarchical taxonomies
Hierarchical taxonomy ordering helps in further structuring content based on parent and child taxonomies.
For example, WordPress categories are hierarchical in nature. If you sell apparel on your website, you can add sub-categories such as shirts, caps, shoes, etc. You can further bifurcate these categories into subcategories to better structure your content type. (for example, sneakers, boots, running shoes).
On the other hand, WordPress Tags are flat and do not follow any hierarchical order. They are usually used to label specific topics on a page.
Creating hierarchical taxonomies is pretty straightforward. While adding new taxonomies, simply tick the checkbox for hierarchical taxonomy.
You can also edit an existing taxonomy by clicking on the Taxonomies button for the respective post type. Click on the edit button for the said taxonomy, enable the checkbox and click on the Update taxonomy button. You can check if the taxonomy terms are hierarchical or not from the manage taxonomies page. It will look like this:
Now that we have our taxonomies in place, let’s see how you can group/filter posts and display it to the website visitors with the Posts Table Pro plugin.
Step 2: How to add custom taxonomies to post tables
Even if you create a dozen taxonomies for your post types, it will have near to no effect on the website’s frontend on its own. You need to display or filter posts by taxonomy to display the posts in that particular post type.
For this, we’ll be using the Posts Table Pro plugin. Posts Table Pro comes with the option to display any website content in a well-structured tabular format. Not just displaying, but you can allow your customers to sort, filter, and perform keyword searches easily.
But before we can start using the plugin, you need to install and activate it on your website. Here’s how you can do it.
Installing Posts Table Pro plugin
If you don’t have a copy of the plugin, you can get it here.
- In your WordPress admin dashboard, go to Plugins → Add New.
- Upload the Posts Table Pro zip file to your website and install it.
- Once the installation is complete, click on the Activate button.
Posts Table Pro should now be active on your website.
Displaying custom taxonomy content with Posts Table Pro plugin
There are multiple ways you can incorporate custom taxonomies on your content display with Posts Table Pro. Here’s how:
- Custom taxonomy filters - With Posts Table pro, you can add custom taxonomies as dropdown taxonomy filters above your posts table and allow your users to filter content based on taxonomies.
- Custom taxonomies as sortable columns - In addition to displaying content taxonomies in individual columns, you can let your website visitors sort the table rows by simply clicking on the table column heads.
- Display posts with specific taxonomies - If you only wish to display posts of a specific taxonomy, you can do it simply by adding the taxonomies in the shortcodes. More on this in the next section.
- Default sorting by taxonomies - With this option, you can make the table have a default sorting order based on a taxonomy when it first loads. This, too, can easily be set up with the help of the shortcodes feature of the Posts Table Pro plugin.
And the best part is that all these uses of taxonomies in Posts Table Pro can be implemented in minutes. Let's see how you can use the plugin settings page to display taxonomies.
Displaying custom taxonomies as sortable columns and dropdown filters
You can make changes to Posts Table Pro from the plugin settings page. To adjust the settings, go to WordPress admin dashboard → Settings → Posts Table Pro.
You'll find a list of options that you can adjust to tweak the tables display.
From the Columns option, you can add your custom taxonomy as a column. Simply add the custom taxonomy slug/permalink along with
tax: prefix in the column text field. For example, if you wish to display 'Genre' taxonomy as a column, here's what you need to add -
tax:Genre separated by a comma in the Columns field.
To allow viewers to use custom taxonomy filters, you need to make changes to the Controls → Search filters. Here, you can either create a custom dropdown list or let the table automatically add filters based on columns in the table. To add a new taxonomy as a custom taxonomy filter option, simply add the taxonomy with
tax: prefix. So, to add a 'Genre' taxonomy, add
tax:Genre separated by a comma.
Displaying the table on your site
To display content in tables, you’ll need to use the
[posts_table] shortcode to display a post table. You can simply copy-paste this shortcode anywhere you wish to display the posts table.
To show posts only from a particular taxonomy, you simply need to add the
term attribute along with taxonomy terms to identify them. For example, if I want to show posts in a table with taxonomies as adventure, thriller, and action, here's what the shortcode would look like:
Further, to make any other customizations to the list, you can tweak the Posts Table Pro plugin settings to adjust the contents, ordering, post types, columns, etc.
Check here to learn more about how you can use the shortcode feature of Posts Table Pro.
Over to you!
Creating custom taxonomies is a great way to structure and organize your website content. If you have a requirement to structure your website’s content in a specific way, chances are you can do it by creating custom post types and custom taxonomies in no time. For this, the Easy Post Types and Fields plugin is just excellent. It does not require any advanced customizations and gets the job done in minutes.
For displaying the structured content based on taxonomies, Posts Table Pro is a no-brainer. Not just for displaying custom post types and taxonomies, you can use it to display content tables with multiple customization options. Here are some of the most popular features of the Posts Table Pro plugin:
- List and filter posts, pages, and any other custom post types.
- Display content based on taxonomies and custom fields.
- Allow visitors to filter, sort, and perform keyword searches.
- Display any kind of content in a sleek table format.
- Control what appears in a table.
- Display filtered content with a simple shortcode.
Now that you know how to create custom taxonomy in WordPress, what are your thoughts on our new Easy Post Types and Fields plugin for WordPress? Did you find it useful? Tell us your experience in the comments section below!