- Overview
- Transcript
3.1 Taxonomies Overview
In this lesson, you'll learn about the taxonomies that come bundled with WordPress and how to use them.
Related Links
1.Introduction1 lesson, 01:00
1.1Introduction01:00
2.WordPress Post Types3 lessons, 25:02
2.1Introducing Post Types06:22
2.2Registering a Custom Post Type09:30
2.3Post Type Template Files09:10
3.WordPress Taxonomies4 lessons, 29:39
3.1Taxonomies Overview06:31
3.2Registering a Taxonomy08:21
3.3Understanding Taxonomy Terms09:21
3.4Taxonomy Template Files05:26
4.Custom Fields and Post Metadata1 lesson, 05:33
4.1Adding and Displaying Custom Fields05:33
5.Conclusion1 lesson, 02:48
5.1Conclusion02:48
3.1 Taxonomies Overview
Hello, and welcome back to this Tuts+ course on custom content types in WordPress. In this part of the course, we'll move on from looking at custom post types to taxonomies. And before we start creating our own custom taxonomies, I'm gonna show you exactly how taxonomies work and what they are. So WordPress comes with a couple of taxonomies out of the box, and those are categories and tags. And you access those through your posts, because they apply to posts. So here, you can see in the menu, I've got categories and tags, and I've already added some categories to this site. Now, categories are a bit like sections of your site. They're high-level ways of subdividing your content, and creating a way of organizing your site that helps people find what they might be interested in. So for example, in this site, which contains blog posts about WordPress, you can see that there are high-level categories. Basics, Essentials, and Ultimate are about the level of experience you need, relating to those posts. And then Roundups and Applications are specific types of content. Now, these are used to organize the site. So this dummy site that I'm using here, I'll show you the live site that it's based on. So this is one of my sites, and you can see here that I've got Basics, Essentials, Ultimate, and Applications as sections of the site. And that is how you would normally use your categories. Now, tags are a bit different. So going back to my demo site, and click on Tags here, you can see that there are a lot more of them. In fact, there's three screens worth of them. So you don't use tags to organize your site. But what you do do is, you use them to highlight specific topics that you might have written about in your posts. So if I go back into this site, you can see, there's a tag cloud. So the tags that are larger in my tag cloud are ones that are used in more posts. So WordPress, for example, is about as big as it gets. Because there's more posts on WordPress than there are on, because there are more posts on WordPress than there are on some of the other topics. So I go back to one of my categories here. You can see that a category has got even more in it, because I've got fewer categories, and everything goes into one or two categories. Whereas the tags, something might just have one tag, or it might have half a dozen tags. Tags are used to help people find topics that they might be interested in, but aren't fundamental to the organization of your site. They're also not hierarchical, so when you create a category, and let me go into the category screen here, you can create subcategories. So here, you could create a category, and give it a parent category of one of these existing top-level categories. Now, I don't often use categories in a hierarchy. But it's definitely something you could do to help with the organization of your site, and help you divide your content up. So those are tags and categories. Now, each of those is a taxonomy, and you can also create your own taxonomies. People sometimes get confused between taxonomies and categories, in particular, and they think that taxonomy is the same kind of thing as category. Actually, category is a subset of taxonomy. So if you create a custom taxonomy, in this case, we're going to be creating a custom taxonomy called Country. Country has the same status, and works in the same way in WordPress as category. And I would add Countries, which are terms in that taxonomy, to my list. And then I would assign each of those terms to one or more of my posts. So categories are similar, the terms for the taxonomy of categories, a category is a taxonomy. These categories here are all taxonomy terms in the category's taxonomy. So as far as how WordPress works under the hood, and how the database stores data, these categories and any terms under your custom taxonomy are treated in exactly the same way. And just as with custom post types, you can create as many custom taxonomies as you want, and some plugins create a number of them. For example, a plugin like WooCommerce creates a few taxonomies for you to use when you're organizing your products. I've created client sites with multiple taxonomies in them, to help those clients categorize, or sort. I'm trying to avoid the use of the word categorize, in relation to anything other than categories. To help clients organize and sort information and data within their site. And you can apply your taxonomies to any post type. So you might create a taxonomy that applies to your posts, or even to your pages. But you might just as well, and this is more common, probably, create a taxonomy that applies to a custom post type you created. So going back to the example of WooCommerce and other e-commerce plugins. You would create a custom post type of product, and then you might create a a custom taxonomy of product categories. And then you wold create terms in each of those, which would relate to each of the categories in your store. It is a little bit confusing that WooCommerce calls them product categories, but it might be helpful to think of them as departments. You can create your own custom taxonomies by registering those taxonomies. And when you've done that, they will appear in the menu underneath whatever post type they apply to. So I've registered a custom taxonomy,, which I'm going to show you how to do in the next part of the course, which doesn't relate to posts. But it does relate to my custom post type of Cities, and that's Countries. So I access it through the Cities menu. And you can see that there is a very similar screen to the one that you would use for categories, and for tags, for adding new Countries and for editing them. So just as with categories and with tags, I can add a description. And that description would be shown at the top of my archive page for an individual country. So all of the cities listed on that archive page would come below the description for the country. So that's how taxonomies work in WordPress. In the next part of the course, I'm gonna show you how to register your own custom taxonomy. See you next time, and thanks for watching.