Taxonomy sounds like a word from a biology class, but in WordPress it is pretty simple. A taxonomy is nothing but a way to group your content.
You already use taxonomies if you have ever added a category or a tag to a post. Knowing the term helps once you work with custom post types or online stores.
What is a taxonomy in WordPress?
A taxonomy is the grouping system, and each item inside it is called a term. For example, Category is a taxonomy, while Recipes and Travel are terms in it.
Just like a library sorts books by genre and by author, WordPress can sort the same post in more than one way. These are the built-in taxonomies you will see most:
- Categories: Hierarchical, so terms can have parents and children.
- Tags: Flat, with no parent and child relationship.
- Post formats: Labels like Aside, Gallery, Quote or Video, available when your theme supports them.
What is a custom taxonomy?
A custom taxonomy is one you create for your own needs. Say you run a movie review site with a custom post type called Movies. You could add a Genre taxonomy with terms like Comedy and Drama, and a separate Director taxonomy.
WooCommerce, for example, adds product categories and product tags this way.
How to create a custom taxonomy
- First, decide which post type the taxonomy belongs to and whether it should be hierarchical.
- Now, register it with the
register_taxonomy()function, or use a plugin that adds custom taxonomies from the dashboard. - Next, give it clear labels and a short slug for its URLs.
- Finally, add terms and assign them to your posts.
Put custom taxonomy code in a site-specific plugin rather than your theme. Otherwise, the taxonomy vanishes from the dashboard when you switch themes, even though its terms stay in the database.
For a beginner-friendly walkthrough, read our lesson on WordPress custom taxonomy. Taxonomies often pair with custom post types, so see how to create a custom post type too.
So, a taxonomy is simply a way of grouping content, and terms are the groups inside it. That's all for now. If anything is unclear, let us know in the comment section below.