Join Morten Rand-Hendriksen for an in-depth discussion in this video What are custom taxonomies?, part of Create an Online Portfolio with WordPress.
- View Offline
When I say custom taxonomy, you may very well wonder, what on earth is taxonomy? A taxonomy is a system of classification that allows you to order items into groups or categories. In the regular posts, you have two types of taxonomies: categories and tags. Taxonomies are found everywhere in real life, from libraries to music stores, to the local farmer food stand. A taxonomy is simply a method of grouping and organizing content. So it follows that in WordPress, a custom taxonomy is a new way of organizing content.
WordPress allows for two types of taxonomies. You have the hierarchical taxonomy like Categories. You can see it if we go in and create a new post. You have Categories down here and you can make subcategories of each category. Now we also have non- hierarchical taxonomies, like tags. Tags live on their own and you can stack multiples next to one another. These are used for different purposes. Which one works better for your type of organization depends on what kind of information is gathered.
This is easier to explain if we'd look at our example project. Under the Culinary Artistry website, we have a large set of different taxonomies. Some that span multiple post types and some that are individual. If you look at them we have of course under Blog, the standard Categories and Tags. Under Recipes, we have Meal Type, which is to indicate things like dinner, desert, lunch ,and so on. We have Ingredients, we have Difficulty level, and you have Time and Portions. Now of the five of these, one should be non-hierarchical.
Can you guess which one? It should be the Ingredients. That's simply because when you insert Ingredients, you are really just inserting a long list of different items that don't really have a relation to one another. It's hard to say that, for instance, bananas relate to tomatoes in a certain way. Whereas Meal type, Difficulty, Time and Portions actually can relate to each other. You can say you could have time, one to two hours, and under there you can have a more specific time like an hour and 40 minutes, or under Meal Type you could say, dinner, and then under there you could have appetizer, main course, stuff like that.
We also see that we have some taxonomies to work across all the new post types while others are individual for them. That's because each individual post type might have specific sorting systems that don't apply to the other ones. This also becomes clear if we think about other types of items. Let's say you make a website that's about cars and motorcycles. Then under both cars and motorcycles you may have a taxonomy called Mak, that defines what make the car or motorcycle is, and many companies make both, so therefore,it should go across both. Whereas if you have one that's called Model, then maybe each should be its own taxonomy, because the models for cars are quite different from the models for motorcycles.
Choosing what taxonomy is to use really depends more on what kind of content you are sorting and how you want to sort it than it does what can and can you not do in WordPress. The basic premise is you can add as many taxonomies you want, you can apply them in any post type, including the original blog post types, and you can apply them in any way you want. It's simply a matter of how you set it up. By adding custom taxonomies to your custom post types, you add the ability to sort the content and find what you're looking for easier. Understanding the difference between hierarchical and non-hierarchical taxonomies, and when to use each can make the site easier to navigate both for administrators and for visitors.
- Exploring online portfolios
- Creating the site architecture
- Incorporating advanced custom post type functionalities
- Hooking a custom taxonomy to a post type
- Understanding how hierarchy relates to taxonomies
- Populating content into custom post types
- Handling multiple post type templates
- Displaying a list of links to the latest custom post type posts
- Building static pages for the front and the blog
- Creating a contact page with a contact form