If you‘re new to WordPress, you may be wondering: what are these "terms" and "taxonomies" I keep hearing about?
In this beginner‘s guide, we‘ll demystify these concepts for you.
After 15+ years as a WordPress developer, I want to share my expertise to help newcomers master terms and taxonomies. This knowledge will level up your site-building skills.
Contents
What is a Taxonomy in WordPress?
A taxonomy is a way to group, categorize and relate content in WordPress. The two default taxonomies are:
-
Categories – For general content grouping.
-
Tags – For micro-categorizing content with keywords.
But you can also register custom taxonomies for specialized content types. Some examples:
- "Genres" for books
- "Brands" for products
- "Subjects" for courses
With custom taxonomies, the possibilities are endless!
Taxonomies help users easily navigate and find related content. And they provide structure for organizing your site.
What are Terms?
Terms are the labels inside a taxonomy. For example, some common terms inside the default "categories" taxonomy are:
- News
- Technology
- Sports
- Politics
Terms allow you to categorize content in a meaningful way for users. You can have any number of terms within a taxonomy.
Tags work in a similar way. Common tag terms might include "wordpress", "beginner", "tutorial". Tags terms help users find very specific content.
Registering a Custom Taxonomy
Registering a custom taxonomy in WordPress takes a bit of code. Here‘s a simple example:
function create_custom_taxonomy() {
$labels = array(
‘name‘ => ‘Genres‘,
);
$args = array(
‘labels‘ => $labels
‘hierarchical‘ => true
);
register_taxonomy(‘genres‘, ‘post‘, $args);
}
add_action( ‘init‘, ‘create_custom_taxonomy‘, 0 );
Some key points:
- Use the
register_taxonomy()
function - Choose taxonomy name – e.g. ‘genres‘
- Pass
$labels
and$args
arrays - Add the ‘init‘ action to register
This will register ‘Genres‘ taxonomy for the post post-type. Now you can start adding term Genres!
Custom taxonomies open up so many possibilities for organizing content. But make sure to only add taxonomies that make sense for your content model.
Displaying Taxonomy Terms
The primary way to display taxonomy terms in WordPress is using template tags. For example:
<p>Categories: <?php the_terms( $post->ID, ‘category‘ ); ?> </p>
This would output the categories for a post. You can display terms from any taxonomy, including custom ones.
Some other useful term template tags include:
get_the_terms()
– Returns array of term objectsget_the_term_list()
– Outputs linked term listget_term_link()
– Generate term archive link
These provide more options for customizing term output, like:
- Before/after text
- Custom term separators
- Term link structure
- Term meta data
- And more…
With some coding knowledge, you have total control and flexibility over term display using template tags.
Going Beyond Template Tags
For site editors without coding skills, there are plugins that allow you to display taxonomy terms without touching template files:
- Shortcodes – Embed a [shortcode] to output terms anywhere.
- Widgets – Add a custom terms widget to sidebars.
Term plugins provide an easy shortcut. But template tags are more powerful for developers writing custom themes.
Advanced Uses for Taxonomy Terms
With terms and taxonomies, you can do more than just categorize content. Some examples:
Use terms to generate nested navigational menus. For example, a "Genres > Fiction > Mystery" nested menu.
Content Filtering
Let users drill down deep into content by filtering on terms across multiple taxonomies.
User Profiles
Assign users custom taxonomy terms to segment them (e.g. "Experience Level") and change their experience.
…And So Much More!
Terms and taxonomies are a core part of WordPress. Once you understand them, you can really take your sites to the next level.
I hope this guide has helped demystify terms and taxonomies for WordPress beginners. Let me know if you have any other questions!