What is the difference between custom fields and taxonomies?
When you use the Easy Post Types and Fields plugin to add custom post types to your WordPress website, you can also create custom fields and taxonomies. This article explains what is the difference between custom fields and custom taxonomies. It also contains advice on how to decide which ones to use for storing different types of information.
What is a custom field?
Custom fields add extra fields of data to a WordPress post or custom post type. They are also known as meta fields.
Each custom field is stored separately in the WordPress MySQL database. As a result, you can store information in a custom field and display it on your website independently from other fields, such as the main content of your posts.
All WordPress posts (or custom posts) have various built-in fields, such as the title, main content, excerpt, and published date. You can extend them by adding custom fields for storing extra data such as a reference number, extra image fields, links, dates, etc.
For example, if you have a 'Portfolio' custom post type then you might create custom fields for the client's name, website address, and the project date. You can then list your portfolio posts in a table on your website using a plugin like Posts Table Pro, with columns for Client, Website, and Project Date.
What is a custom taxonomy?
A custom taxonomy is a way of organizing and grouping information your posts or custom posts. You're probably already familiar with the categories and tags that you get for normal WordPress posts. Custom taxonomies are just like this.
There are two types of custom taxonomy:
- Hierarchical taxonomies - These are like categories, where you can create hierarchical parent-child relationships of categories and sub-categories. This lets you create nested structures, with an unlimited number of levels.
- Non-hierarchical taxonomies - These are flat, like tags. You can add as many terms as you like, but you can't structure them into multiple levels.
For example, if you've created a 'Portfolio' custom post type then you might create a custom post type called 'Industry'. You would use this to tag each portfolio post with the client's industry or sector. On the front end of your website, you might use a plugin like Posts Table Pro to list the portfolio posts in a table with an 'Industries' filter so that users can filter by their own industry.
Should I use a custom field or taxonomy?
Now you know the difference between custom fields and taxonomies in WordPress, it should already be a bit clearer which to use in different situations. The following questions will help you to decide for definite:
- Will you use the field to store different information for each post? If so, then you should use a custom field.
- Will you use the data to organize and group your posts? Do you want your users to be able to filter by the data to narrow down the list? If so, then you need a custom taxonomy.
How to create WordPress custom fields and taxonomies
You can use the free Easy Post Types and Fields plugin to add both custom fields and taxonomies to your custom post types.