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.
Toolset Types plugin makes it easy to add custom taxonomy to any custom post type. You will be able to add custom taxonomy to the standard “posts” and “pages” or to create your own custom types and add taxonomy to them.
In this page:
- Hierarchical and Non-Hierarchical Taxonomy
- How to Create WordPress Custom Taxonomy
- Together with Taxonomy – Custom Post Types and Custom Fields
- Displaying taxonomy on the site’s front-end
- Displaying posts that belong to the taxonomy using Custom Taxonomy Archives
Hierarchical and Non-Hierarchical Taxonomy
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. | Non-hierarchical taxonomy works exactly like post tags. You enter the text for different terms and can choose from a list of ‘most used’. |
---|---|
|
|
How to Create WordPress Custom Taxonomy
Go to Toolset->Dashboard, locate the custom post type for which you want to add the taxonomy and click on New taxonomy. If this is new to you, start with the tutorial on creating custom post types.
In this example, we’ll create a new custom taxonomy called “property type” for a real estate site.
1. Give Your Taxonomy a Name
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 the publish state of the custom taxonomy
You can control if the custom taxonomy is active and published, or set it into a draft mode. To do this, when creating or editing a taxonomy, click on the Edit link, next to the Status setting in the Save box.
Taxonomies in a draft mode are not available in admin menus and user interface. Additionally, and you cannot query them on the front-end.
3. Select Post Types
Since you created the taxonomy from the Toolset Dashboard, it’s already connected to the correct custom post type.
You can connect the taxonomy to other post types. Using the same taxonomy for different types will allow you to connect between them and create advanced content displays on the site’s front-end.
4. Assign Labels
Labels are the texts that describe, in the WordPress admin, the different actions available to taxonomy. By default, your custom taxonomy will have the same labels as all other WordPress taxonomy. You can change it, if you need.
5. Advanced Settings
The advanced settings offer you access to additional features of the taxonomy:
- Taxonomy type – this is an important option for determining the form of your taxonomy. A hierarchical taxonomy will behave the Category taxonomy, flat will be like tags. For the Property Types category we’ll choose hierarchical
- 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
- query_var – uncheck to prevent queries
- update_count_callback – use to write custom functions
- Hide taxonomy meta box – if you select this, there will be no meta box on entry edit screen.
- meta_box_cb – Meta box callback function provides a callback function name for the meta box display
Click save.
6. Add Terms
Once you’ve saved the custom taxonomy (and if it’s visible), it will appear inside the WordPress menu, under the custom content type, to which it belongs.
In order for writers to see taxonomy items to choose from, you should add them.
Add as many terms as you wish – you’re now ready to classify your post type!
Together with Taxonomy – Custom Post Types and Custom Fields
Custom taxonomy lets you organize content. Most sites that use custom taxonomy also need custom post types and custom fields.
Displaying taxonomy on the site’s front-end
There’s a lot that you can do with taxonomy on the site’s front-end. You can include taxonomy terms in templates, filter lists by taxonomy and include it in custom searches.
If you are comfortable editing PHP, you will be able to display custom taxonomy on the front-end using the WordPress themes API. You can display taxonomy without writing PHP using the full Toolset package. We offer refunds for up to 30 days for Toolset, so you can try it, risk free.
See these subjects for different ways to display and use taxonomy:
- How to design the front-end display of custom post types using Content Templates
- How to display custom post types anywhere on the site’s front-end using Views
- Creating custom post archives
- Create custom searches by custom fields and taxonomy
Displaying posts that belong to the taxonomy using Custom Taxonomy Archives
One of the major benefits of using custom taxonomy is being able to display, on the front-end, posts that belong to that taxonomy.
For example, say you have an invoice content post type that contains information regarding different employees in your company. You might want to group these invoices. One invoice belongs to a regular employee, while the other invoice would belong to a contractor.
You can see that there are two taxonomies added for the “invoices” post type: ’employee’ and ‘contractor’. The next step is to now assign a taxonomy to your custom post types. This is done by editing the post.
Here, let’s assign ‘Permanent’ to some invoices under the regular “employees” taxonomy.
And assign ‘Temporary’ for “contractors” taxonomy.
The resulting custom taxonomy archive URL will look like this:
http://www.example.com/employee/permanent/
http://www.example.com/contractor/temporary/
Each of these pages will include a list of the posts (invoices) that belongs to the taxonomy.
To design custom taxonomy archives with Toolset, go to Toolset->WordPress Archives and click on Add new WordPress Archive. Then, choose that this archive is for the custom taxonomy that you’ve created.
Proceed with the instructions for using WordPress Archives to design how this archive looks on the front-end.
Creating Taxonomy Archives Using PHP
If you are using only the Types plugin, you can edit the PHP files of your theme to create custom taxonomy archive pages on the front-end. You can read more about this topic on our page about creating taxonomy archives using PHP.