I was under the impression you can't have categories and tags on
custom post types?
You can have categories and tags on custom post types!
But I can't see how Taxonomies and Terms are the
But they are the same, Categories are a taxonomy, as are post tags, they're stored in the database the same way as custom taxonomies, and use the same code and user interface.
The part that makes custom taxonomies "custom" is that it wasn't WP Core that registered them, it was you/a plugin.
Having said that, categories and tags have some legacy baggage that shows in certain file names, and some category/tag specific APIs. For the most part these can be ignored, and they have no bearing on custom taxonomies. Custom post types are in a very similar boat
And if you can have categories and tags on custom post types
what is the reasoning for using custom Taxonomies? It's all very
There's a few reasons:
- What if I want to show different categories of a
product post type with just the products?
- What if I want to list all categories next to posts, but some of those categories have nothing to do with posts because they're only used for a custom post type?
- What if I want a taxonomy that is not a category or tag? E.g. country? Colour? Size?
A taxonomy is just a way to filter/group things together. Taxonomies have terms that are then used as boxes to group them together.
If you want to group X by Y, Y is a taxonomy, and X is a post type.
E.g. I want to group products by colour.
An example of a colour would be red, green, yellow, these are terms in the colour taxonomy.
Terms can be hierarchical, or non-hierarchical. E.g. Categories versus tags. I could extend the colour taxonomy example to say it is hierarchical, and that the yellow term has child terms for goldenrod or banana yellow.
So any time that you want to group posts by something, that's what taxonomies are for.
Also, anytime you need to filter/include/exclude posts by something, use a taxonomy. Some people store a post meta flag and then do a meta query, incurring a disastrous performance penalty. Just use a taxonomy instead, e.g. a
show_on_homepage taxonomy with a
yes and a
no term, can be hundreds of times faster than a custom field.