Custom taxonomies in WordPress: A guide

how to create custom taxonomy in wordpress using posts table pro

Looking for an easy way to create custom taxonomies in WordPress? Every WordPress website comes with two taxonomies: categories and tags. If you want to further organize the content on your website, this easy step-by-step guide will help you create, display, and filter by a custom WordPress taxonomy.

What is a taxonomy in WordPress? WordPress taxonomies make it easy to structure and group content on a website. For example, a niche book review website might have a 'Book Types' taxonomy for filtering content. It might also have custom sub-taxonomies such as Classics, Fantasy, or Thrillers to further structure the content.

In this guide, you'll learn:

  • What are custom taxonomies?
  • How to create custom taxonomies with new custom post types.
  • How to create WordPress custom taxonomy 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:

table built with posts table pro
A list of WordPress posts with a column and filter dropdown for a 'Country' taxonomy

If you are a beginner WordPress user, then 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 custom taxonomy function helps organize the content on a WordPress site.

By default, every WordPress site has two taxonomies:

  1. Categories
  2. Tags

You can use them to group or structure blog posts and pages on your website fairly quickly.

default taxonomies in WordPress

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 WordPress content.

Custom taxonomies can be hierarchical too. This means your WordPress custom taxonomy terms can have sub-categories to further define the website’s content type structure. For example, a movie review website might have a category like ‘Action’, which can further have sub-categories like ‘Disaster Movies’, ‘Superhero Movies’, or ‘Spy Movies’:

  • 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 a WordPress custom taxonomy is. Let’s learn how to create them.

How to create custom taxonomies in WordPress

There are some excellent free plugins available to create a WordPress custom taxonomy. In this tutorial, we’ll be using the free Easy Post Types and Fields plugin.

easy post types and fields plugin

We designed this plugin with the aim to make the process of creating custom post types and taxonomies more simplified. It doesn't require touching a single line of code or adding code snippets.

So, let’s see how you can set it up. First, here's a video on how you can create custom taxonomies for WooCommerce products. The process is practically identical for adding them to any type of WordPress content:

1. Install Easy Post Types and Fields

  1. Login to your WordPress admin dashboard and go to Plugins → Add New.
  2. Now search for 'Easy Post Types and Fields'. Install and activate the plugin with the author 'Barn2'.
  3. You’ll be redirected to the setup wizard. If you wish to create custom post types with taxonomies, then you can use this wizard. But if you wish to just create custom taxonomies, then click the Skip Setup Wizard link.
setup wizard easy post types

2. Create custom taxonomies

You can create custom taxonomies for existing post types (e.g. pages or posts). Alternatively, you can create custom post types alongside creating new custom taxonomies. For example, you might create a 'Resources' post type with a 'Topics' custom taxonomy.

Let’s check out both of them one by one.

Option 2a: Add custom taxonomy to existing post types

We know that WordPress has its own default custom taxonomies: Categories and Tags. To extend this and add custom taxonomies to existing post types, follow these steps:

  1. First, go to Post Types → Manage in your WordPress admin dashboard.
  2. Next, head over to Other Post Types by clicking on the tab. You will find this right next to the Easy Post Types tab.
  3. Now click on the Taxonomies button for the post type you want to update. Here I am adding a new taxonomy to Posts.
    Manage post types
  4. 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.
  5. Click on Add taxonomy button.

New custom taxonomy for existing post types is now successfully added. Now you can add individual terms for the taxonomies.

Option 2b - Create a new custom post type with taxonomies

In this scenario, we'll create a new post type with its own WordPress custom taxonomies:

  1. Go to Post Types → Manage → Add New in your WordPress admin dashboard.
  2. Give your post type a singular name as well as a plural name. For example, Movie (Singular) and Movies (plural). Click on the Next button.
  3. From the checkbox list, select the type of information you want the custom post type to have. Then, click on the Create button.
New post type for adding taxonomies

Your custom post type is now ready. Now you’ll find the links to add custom fields and taxonomies:

  1. To create a custom taxonomy, select the Add taxonomies button.
  2. You’ll be redirected to the custom taxonomies page. Click on the Add New button to add a new item.
  3. Give your taxonomy a singular name and a plural name.
  4. Click on the Add Taxonomy button.
add custom WordPress taxonomy

After adding custom taxonomies, it will show up on 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:

manage wordpress 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 also 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, and running shoes).

Simultaneously, 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.

Additionally, you can edit taxonomies 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:

hierarchical taxonomies

Now that we have our taxonomies in place, I'll show you how to group/filter posts and display them to the website visitors.

How to display custom taxonomies on your WordPress website

Even if you create a dozen taxonomies for your post types, it will have near to no effect on the website’s front end on its own. You need to display or filter posts by WordPress taxonomy to display the posts in that particular post type.

custom filtered content by taxonomy
Posts filtered by 'Year' taxonomy.

We'll use the Posts Table Pro plugin for this. Posts Table Pro comes with the option to display any website content in a well-structured tabular format. Not just displaying. You can also allow your customers to sort, filter, and perform keyword searches easily.

Displaying custom taxonomy content with the Posts Table Pro plugin

If you don’t have a copy of the plugin, you can get it here.

  1. In your WordPress dashboard, go to Plugins → Add New, upload the plugin's zip file, and install the plugin.
  2. Follow the setup wizard instructions to create your first table:
    1. Start by giving your table a name and selecting the post type you wish to display.
    2. Next, select the posts or pages you would like to include in the table. The available options will vary based on the post type you selected in the previous step. For instance, if you chose a post with custom taxonomies, then the relevant taxonomies will be listed for you to select.
    3. Customize your table to suit your preferences. You can determine which columns to display and in what order, including custom taxonomy columns. To add a new column, choose the column type from the dropdown menu and click "Add". You can also reorder columns by dragging and dropping the sort icon or column heading.
    4. Add WordPress custom taxonomy filters to your table to improve user experience. Filters appear as dropdowns above the table and can be customized according to your preferences.
    5. Finally, the wizard will confirm that you have finished creating your table and provide instructions for inserting it onto your site.

Displaying the table on your site

After creating your table, the next step is to decide where to display it on your website. There are two ways to add a table to your WordPress site.

  • If you're using the Gutenberg block editor, you can simply select the 'Post Table' block and insert the table directly from the block settings.
  • Alternatively, you can copy the shortcode from the last page of the table builder or from the main Tables page in the Post Tables section of the WordPress admin. You can then paste this shortcode on any page where you want the searchable database to appear. This way, you can place the table on any page regardless of its topic or content.
WooCommerce table search on click true

FAQ

What are the benefits of custom taxonomies in WordPress?

Custom taxonomies in WordPress provide several benefits, including:

  • Better content organization: Custom taxonomies allow you to categorize your content in a way that makes sense for your website, rather than relying on WordPress's default categories and tags.
  • Improved user experience: By grouping related content under specific taxonomies, it makes it easier for your website visitors to find what they are looking for and navigate your website with ease.
  • Increased relevance: Custom taxonomies can help you to create more relevant and targeted content by allowing you to categorize content by specific topics, genres, or themes.
  • Improved SEO: Custom taxonomies can help your website's search engine optimization (SEO) by providing a more structured and organized way of categorizing your content. This makes it easier for search engines to understand the structure and content of your website.
  • Enhanced customizability: Custom taxonomies give you the ability to create custom templates and styles for your taxonomy archives, providing you with a greater level of control over how your taxonomies are displayed on your website.

Custom taxonomies are a powerful tool that can help you to better organize and structure your content, improve user experience, and enhanced the overall look and feel of your website.

What's the difference between categories, tags, and custom taxonomies?

Confusingly categories, tags and custom taxonomies are all taxonomies!

Basically, categories and tags are a type of taxonomy that comes with WordPress by default. Custom taxonomies are just like categories and tags, but they are additional taxonomies which you create yourself. They provide additional ways to group and sort content on your site.

How many custom taxonomies can I create in WordPress?

You can create an unlimited number of custom taxonomies in WordPress. However, I recommend keeping things organized and planning the best way to structure them.

For example, if you've created a WordPress member directory and want to store data about each member's country and city, then you may not need to create a taxonomy for each country. Instead, create a single 'Location' hierarchical taxonomy which is neatly structured into countries, states, cities, and so on.

How do custom taxonomies work with WordPress themes?

All WordPress themes are designed to work with custom taxonomies. You won't need to do any extra styling or CSS code unless you specifically want your taxonomy archives to look different from your blog posts. In that case, you can add a separate template for the custom taxonomy to your child theme.

How to create custom taxonomy in WordPress via coding

This is for developers or someone who likes taking the technical approach to making WordPress theme customizations. With the following code, you can create custom taxonomies through coding.

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 WordPress 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. If you’re unsure then I recommend using a plugin or using our customization service.

Do custom taxonomies affect SEO?

Each custom taxonomy has its own archive page, which looks similar to your blog category pages. This can be indexed in search engines and help your SEO.

If you use a plugin like Yoast SEO then you can easily choose whether or not custom taxonomy archives will be indexed in search engines.

Harness the power of custom taxonomies

Creating custom taxonomies is a great way to structure and organize your WordPress website's content. The Easy Post Types and Fields plugin is perfect for this, as it gets the job done in minutes.

Once you've created custom taxonomies, you can use the Posts Table Pro plugin to list your website content in a searchable table complete with custom taxonomy columns and filters. This makes it easy for visits to view and search by taxonomy, quickly finding the exact information they're looking for. It's ideal for portfolios, blog posts, products, or any other type of content:

  • List and filter by custom taxonomy for 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.

Please share your thoughts...

Your email address will not be published. Required fields are marked *