How to Create Custom and Register Taxonomies in WordPress

Oloruntobi Awoderu
5 min readJun 7, 2021

This article was first published on the Aeeiee Blog.

A WordPress taxonomy is a way to organize groups of posts and custom post types. This gives you the flexibility to group posts, pages, etc. for your site needs. Fortunately, WordPress comes with some inbuilt custom taxonomies that make it possible to organize contents and posts but unfortunately, those inbuilt taxonomies might not meet your specific need. This is where custom taxonomy comes in and in this article, I am going to walk you through how to create custom taxonomies to meet your specific site needs.

Custom Taxonomies

Custom Taxonomies are useful when you want to create custom groupings/classifications that best explain the relationships between your posts. WordPress provides us with the tools to create Custom Taxonomies and we’re going to look at them in this article.

Why Use Custom Taxonomies?

Custom taxonomies are very important especially when you need your site tailored to your specific needs compared to the traditional “Categories” and “tags” that WordPress comes with.

For example, you might want to build a blog website that features articles about “Movies”. One way to organize the blog might be to create a Custom Taxonomy called “Fiction” to store all the blog posts on fiction, then a Taxonomy called “Adventure” to store posts on Adventure and probably another Taxonomy called “Action” to store posts on movies with an action genre.

The key advantage of using Custom Taxonomies is that:

  • You can reference them, for example, “Fiction” and “Adventure” independently of Categories and Tags.
  • They get their own menus on the Admin Dashboard.
  • It enables you to create custom User Interfaces (UIs) for users on the Admin dashboard which allows users to intuitively group their posts correctly

How to Create Custom Taxonomies in WordPress

There are two ways to create custom taxonomies in WordPress:

  1. The Plugin Method
  2. A programmatic way by using one of WordPress’ inbuilt functions.

Creating Custom Taxonomies With A Plugin

In order to create a custom taxonomy using a plugin, the first thing you need to do is install and activate the Custom Post Type UI plugin.

First, locate the plugins directory in the dashboard.

Second, use the search bar to search for CPT UI plugin and install it.

After installation, navigate to the CPT UI menu on the left side of the dashboard. Click on “Add/Edit Taxonomies” to create your first Taxonomy.

You can fill the form with the settings in the example below. In this example, I used “Movies” as a Custom Post Type.

If you created a custom post type and wanted to attach the new taxonomies to it, it will show up under the Attach to Post Type settings.

You can also choose whether you want your taxonomies to be “hierarchical or non-hierarchical” as seen below.

If your taxonomy choice is hierarchical, this means your taxonomy titled “Movie” can have sub-topics. For example, a Movie with a genre of Fiction can have sub-genres like Fantasy, Thriller, Mystery, and more.

There are many other settings further down your screen in your WordPress dashboard, but you can leave them as-is for this tutorial.

Next, you can click on the “Add Taxonomy” button at the bottom to save your custom taxonomy.

Great! You’ve created your first custom taxonomy. To check the taxonomy you just created, you can navigate to the WordPress sidebar, click on “Posts” or “Pages” or any other custom post type you selected when creating the taxonomy, and your new taxonomy should be available to you.

For example, after creating my “Movies” taxonomy, I could view it under both “posts” and “pages” because I selected the taxonomy to be available to both on creation.

Now that you’ve created a custom taxonomy, you can go to either “pages or posts”, create a new post, and attach the “Movies” taxonomy to the post to help categorize it.

Creating a Hierarchal Taxonomy with code

Notice the difference between both blocks of code. On line 30, the value for hierarchical argument is true for category-like taxonomy and false for tags-like taxonomies.

Also, on lines 20 and 21, note that in the labels array for non-hierarchical tags-like taxonomy, I added null for parent_item and parent_item_colon arguments which means that nothing will be shown in the UI to create parent item.

I hope this article has helped you learn how to create and register custom taxonomies in WordPress. If you have any questions, you can put them in the comments below.

--

--