You have surely heard the term taxonomy in WordPress. However, what is a taxonomy? And how do you create custom taxonomies in WordPress? In today’s blog, we will explain this term and give you a helpful way to add functionality to your WordPress website. Now, let’s dive into the following section.
What are WordPress Taxonomies?
WordPress Taxonomies are great methods of grouping and classifying content and data in WordPress. With a taxonomy, you can group many posts and similar items together. By default, there are two taxonomies in WordPress called categories and tags.
For example, say you want to create a custom post type called “Foods” and sort it by using a custom taxonomy called “Recipes”. Then, you can add multiple terms such as ‘Vegetarian’, ‘Fresh’ or ‘Easy Cooking’. This helps you and your readers easily sort foods by each topic.
Taxonomies can also be hierarchical. For example, when you create main subjects such as Comedy and Action, you can add more subitems under each category.
How to Create Custom Taxonomies in WordPress?
Now, we are going to demonstrate the two methods to add taxonomies:
- Using a free plugin
- Manually with code
Method 1: Create custom taxonomies using Custom Post Type UI
Custom Post Type UI is one of the most powerful WordPress custom post type plugins that comes with an easy-to-use interface for managing custom post types and taxonomies for your website. In addition, it helps you solve the issue of creating custom post types.
As with other plugins, you first need to install and activate the Custom Post Type UI plugin. For more support, you can see our step-by-step guide on how to install a WordPress Plugin for beginners.
After activating the plugin, you will see a new option (CPT UI) in your WordPress dashboard menu. Let’s navigate to CPT UI > Add/Edit Taxonomies.
However, you have to make sure that you created a custom post type before creating your taxonomies.

Under the Basic Settings section, you need to focus on doing the following:
Firstly, you need to create your taxonomy slug. This slug will be used in the URL, and through this URL path you can see all posts under this taxonomy. This slug can only contain letters and numbers, and all letters will be converted to lowercase letters.
Secondly, you need to create the plural label of the taxonomy, for example Actors, and the singular label such as Actor.
Next, you will see the option which displays “Populate additional labels based on chosen labels“. Let’s click on this link and immediately the plugin will auto-fill the rest of the label fields for you. You can also add all the fields by yourself.
The fourth option is about Attach to Post Type. You will see all existing post types listed as checkboxes. Check the post types that you want the taxonomy attached to.

At the Additional Labels section, you can fill in all the fields with the respective label names. Or the plugin will automatically fill these fields, as we mentioned above. In addition, you can also provide a description of your post type.
These labels are used in your dashboard menu when you are editing and controlling content for that particular custom taxonomy.
Next, you see the Settings section. In this area, there is a wide range of options for each taxonomy you generate. You can read a description displayed below each option to understand what it does. Then set it up as you want.

In the image above, you will see that we set up True to make this taxonomy a hierarchical taxonomy, and then it will work like standard post categories (parent-child relationship).
Otherwise, you can make it a non-hierarchical taxonomy by setting that field to False.
In addition, there are plenty of settings displayed on your screen such as shown in nav menu, delete with the user, has archive page, Hierarchical for the parent-child relationship, show in the admin menu, and much more. You can read the description of each field and set it according to your requirements.
Once you are happy with your selections, let’s click on the “Add Taxonomy” button shown at the bottom to save your custom taxonomy.
Now, you can see the new custom taxonomy under your post type. In our case, we made a custom taxonomy for the “movies” custom post type. You can edit the post type associated with this taxonomy in the WordPress content editor to use it.

Method 2: Create custom taxonomies by code snippets
This method is quite complicated because it requires you to add code snippets to your WordPress site. Now, we are going to start with a hierarchical taxonomy that works like categories and can have parent and child terms.
- Creating a Hierarchical Taxonomy
Now, you need to add the following code in your theme’s functions.php file or in a site-specific plugin to generate a hierarchical custom taxonomy that is similar to categories.
//hook into the init action and call create_movie_taxonomies when it fires
add_action( 'init', 'create_subjects_hierarchical_taxonomy', 0 );
//create a custom taxonomy name it subjects for your posts
function create_subjects_hierarchical_taxonomy() {
// Add new taxonomy, make it hierarchical like categories
//first do the translations part for GUI
$labels = array(
'name' => _x( 'Subjects', 'taxonomy general name' ),
'singular_name' => _x( 'Subject', 'taxonomy singular name' ),
'search_items' => __( 'Search Subjects' ),
'all_items' => __( 'All Subjects' ),
'parent_item' => __( 'Parent Subject' ),
'parent_item_colon' => __( 'Parent Subject:' ),
'edit_item' => __( 'Edit Subject' ),
'update_item' => __( 'Update Subject' ),
'add_new_item' => __( 'Add Subject' ),
'new_item_name' => __( 'New Subject Name' ),
'menu_name' => __( 'Subjects' ),
);
// Now register the taxonomy
register_taxonomy('subjects',array('movies'), array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_in_rest' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'subject' ),
));
}
You should note that you have to replace the taxonomy name and labels in the example code with your own taxonomy labels. And of course, this taxonomy is associated with the Movies post type, you can change that to whatever post type you want to use it with.
- Creating a Non-hierarchical Taxonomy
Similarly, in order to create a non-hierarchical custom taxonomy like Tags, you need to add the following code in your theme’s functions.php or in a site-specific plugin:
//hook into the init action and call create_topics_nonhierarchical_taxonomy when it fires
add_action( 'init', 'create_topics_nonhierarchical_taxonomy', 0 );
function create_topics_nonhierarchical_taxonomy() {
// Labels part for the GUI
$labels = array(
'name' => _x( 'Topics', 'taxonomy general name' ),
'singular_name' => _x( 'Topic', 'taxonomy singular name' ),
'search_items' => __( 'Search Topics' ),
'popular_items' => __( 'Popular Topics' ),
'all_items' => __( 'All Topics' ),
'parent_item' => null,
'parent_item_colon' => null,
'edit_item' => __( 'Edit Topic' ),
'update_item' => __( 'Update Topic' ),
'add_new_item' => __( 'Add New Topic' ),
'new_item_name' => __( 'New Topic Name' ),
'separate_items_with_commas' => __( 'Separate topics with commas' ),
'add_or_remove_items' => __( 'Add or remove topics' ),
'choose_from_most_used' => __( 'Choose from the most used topics' ),
'menu_name' => __( 'Topics' ),
);
// Now register the non-hierarchical taxonomy like tag
register_taxonomy('topics','movies',array(
'hierarchical' => false,
'labels' => $labels,
'show_ui' => true,
'show_in_rest' => true,
'show_admin_column' => true,
'update_count_callback' => '_update_post_term_count',
'query_var' => true,
'rewrite' => array( 'slug' => 'topic' ),
));
}
Note the difference between the two snippets. The first one is true for category-like taxonomies and false for tag-like taxonomies.
Additionally, in the labels array for non-hierarchical tag-like taxonomy, we added null for parent_item and parent_item_colon arguments, so nothing will be displayed in the UI to generate parent items.
How to display custom taxonomies in WordPress?
After you have created custom taxonomies, WordPress will not automatically display them. Hence, you need to add some code to your WordPress theme, or child theme to display them.
The following code needs to be added to the template files where you want to show the terms.
Usually, this is single.php, content.php, or one of the files displayed in the template-parts folder in your WordPress theme. It is easy for you to find this file and edit it.
Now, let’s add the following code where you want to show the terms.
<?php the_terms( $post->ID, 'topics', 'Topics: ', ', ', ' ' ); ?>
Moreover, you are able to add it to other files such as archive.php, index.php, and anywhere else you want to display the taxonomy.

How to add taxonomies to custom posts?
Now, you will see that your custom post type (Movies) has a new submenu item: Subjects. Let’s click it.
From here, you can add new items to the Subjects taxonomy. For example, we are going to add “Action”.

On the screen, you need to pay attention to 4 areas including Name, Slug, Parent, and Description.
In the first area, you need to enter the term you want to add. In our case, the “Action” term was added. You can leave the slug part and optionally provide a description for this term.
Then, don’t forget to click on the “Add New Subject” button to create your new taxonomy. Immediately, the new term will be displayed in the right column.
Now, if you navigate to the Movies and Add New page to create a post, you will see the Subjects taxonomy on the right sidebar. On the post edit screen, you can choose from available options or create new terms by clicking on the Add New Subject link.

How to add custom taxonomies to the navigation menu?
After you have created custom taxonomies, you can display them in your WordPress site’s navigation menu.
Simply visit Appearance > Menu and then choose the terms you want to add under your custom taxonomy tab.

Remember to click on the “Save Menu” button to save your changes.
Now, it’s time for you to visit your website to see your menu in action.

If you want to create a beautiful menu, please see our step-by-step tutorial on how to create a drop-down menu in WordPress.
End
Congratulations! If you have read this far, we believe that now you have the ability to create custom taxonomies in WordPress professionally. Hopefully, this post gave you a lot of useful methods to handle your problem. If you have any questions, don’t hesitate to let us know in the comments below.
Moreover, do you already have a beautiful website? Visit our Free WordPress themes to discover a wide range of attractive, SEO-friendly designs for your website.



