WordPress Custom Taxonomies

What is WordPress Custom Taxonomy?

Custom taxonomy lets you organize your custom post types. It’s like categories and tags for posts, but used for any custom type that you define.

You can define hierarchical, or non-hierarchical custom taxonomy.

Hierarchical taxonomy works just like post categories. It appears as a tree and you have checkboxes to select taxonomy terms.

categories on the add new post page

The Categories Non-Hierarchical Taxonomy

Non-hierarchical taxonomy works exactly like post tags. You enter the text for different terms and can choose from a list of ‘most used’.

Tags on the add new post screen

The Tags Non-Hierarchical Taxonomy

Unlike post categories and tags, which are built-in to WordPress, you setup custom taxonomy, specifically for your custom post types.

A real estate website, for example, might want to have the custom taxonomy “Property Type”. With this set up your site visitors could easily filter information based on the type of property they want to view.

How to Create WordPress Custom Taxonomy

With Types it’s easy to create a custom taxonomy – it’s just a matter of filling in the information. Let’s take a look at how to create the “Property Type” taxonomy for a real estate website.

1. Give Your Taxonomy a Name

Navigate to Types > Custom Types and Taxonomies and click “Add Custom Taxonomy

clcik Add Custom Taxonomy

You need to give your taxonomy a name and description. For this taxonomy I’m going to use the following details:

  • Taxonomy name plural – Property Types
  • Taxonomy name singular – Property Type
  • Slug – property-type

2. Choose your visibility

Here you can choose whether you want the taxonomy to appear in the WordPress Admin menu, or if you want to keep it hidden.

set visiblity to visible

3. Select Post Types

You should associate your taxonomy with a post type. I have already created a “Property” post type for a real estate site. You can learn how to do that here. I’m going to associate my Property post type with the Property Types taxonomy.

attach your taxonomy to a post type

4. Assign Labels

Labels are attached to your category name on the admin screen. Check one out in action:

The Add New Property Type label

The defaults are usually fine for these but they are included here so that you can further customize your settings.

5. Advanced Settings

The advanced settings let you further tweak your taxonomy settings.Here is what they mean:

  • Rewrite – rewrite the permalinks. This will use what you have set up in settings > permalinks. You can also prepend your taxonomy name with a custom slug
  • Allow permalinks to be prepended with front base – lets the taxonomy be prepended with a custom slug (such as /blog/, /news/)
  • Hierarchical URLs – implements hierarchical URLs with hierarchical taxonomies. The means your URL could be /property-type/bungalow/3-bedroom/
  • show_ui – decide whether you want to display the UI to manage the taxonomy
  • show_in_nav_menus – determine whether you want to permit this taxonomy to be added to menus
  • show_tagcloud – enables the tag cloud widget for non-hierarchical taxonomies
  • hierarchical – this is an important option for determining the form of your taxonomy. A hierarchical taxonomy will behave the Category taxonomy, non-hierarchical will be like tags. For the Property Types category we’ll choose hierarchical
  • query_var – uncheck to prevent queries
  • update_count_callback – use to write custom functions

Click save.

6. Add Terms

Your taxonomy will now appear underneath the Property post type. Navigate to Properties > Property Type

Fill in your first term. I’m going to add “Apartment”.

add the apartment term

Add as many terms as you wish – you’re now ready to classify your post type!

Want to Learn More?

Types is a free plugin for managing custom post types, custom taxonomy and custom fields.