WordPress Taxonomies on Steroids

June 3, 2017 - WordPress

Taxonomies are generally based either on Categories (hierarhical) or on Tags (non-hierarhical) and can be included in default or custom post types.

Built in Taxonomies

WordPress offers four built-in taxonomies out of the box:
Categories and Navigation menu are hierarhical.
Tags and Links are multifaceted.

Custom taxonomies

Their URL:                 // location is taxonomy    // hotel-review is custom post type

Like with post types, we need to decide where to put taxonomy – in the plugin or in the theme.

Default taxonomies

Taxonomies are saved in wp_term_taxonomy table in the database.
wp_term_taxonomy table

Taxonomy terms are saved in wp_terms table in the database.

Taxonomies Theme Templates

Here are the options.


Output custom taxonomy to a template


<div class="taxonomies">
        <div class="product-type">
                        <?php echo get_the_term_list($post->ID, 'product-type', 'Type of Product: ', ',', ''); ?>
        <div class="price-range">
                        <?php echo get_the_term_list($post->ID, 'price', 'Price Range: ', ',', ''); ?>
        <div class="satisfaction">
                        <?php echo get_the_term_list($post->ID, 'satisfaction', 'Satisfaction: : ', ',', ''); ?>

WP Taxonomy Generator
Codex – Taxonomies
Codex – Register taxonomy
How To Create A Custom Taxonomy In WordPress