Flat vs. Hierarchical Taxonomies
Taxonomies can be divided into main types: hierarchical taxonomies and flat taxonomies. Which one to use depends a lot on the individual scenario. Imagine that you have news articles related cities and states/provinces. Your news article relates to a particular city and State/Province. Therefore a straightforward approach might be to have a single taxonomy with parent terms representing the States/Provinces, and child terms for the individual cities. With this approach, it would be easy to list all the news in a particular place. As for the flat taxonomies, imagine that you have a post type for videos. You want to be able to tag these videos with the names of the people appearing in them. In this case, a flat taxonomy would be the best approach.For clarification purposes, taxonomies and terms are two different things. Terms are each individual item within a taxonomy. For example, “New York” is a term within the “Locations” taxonomy.
Creating Taxonomies
There are two ways you can create taxonomies. You can either add theregister_taxonomy() to the post type plugin in case the taxonomy and the post type are related, or you can create a separate plugin for the taxonomy in case multiple post types will share it.
Please remember to replace
PREFIX with your own project prefix and replace textdomain with your own text domain.PluginName.php