What is a Taxonomy in WordPress? An In-Depth Guide
WordPress is a powerful content management system that makes it easy to organize and classify your content in a user-friendly way. One of the key features that enables this is taxonomies.
In simple terms, a taxonomy is a way to group things together based on shared characteristics. In the context of WordPress, taxonomies provide a convenient way to sort your posts and custom post types into related groups and subgroups. This makes it much easier for both users and search engines to find the content they are looking for.
By default, WordPress comes with two built-in taxonomies – Categories and Tags. Let‘s take a closer look at each of these:
Categories
Think of categories like the table of contents for your WordPress site. They provide a broad, high-level way of grouping related content together. Categories are hierarchical, meaning you can create subcategories within a parent category.
For example, let‘s say you have a food blog. You might have top-level categories for:
- Recipes
- Cooking Tips
- Kitchen Gear Reviews
Then within the Recipes category, you could have subcategories for:
- Breakfast
- Lunch
- Dinner
- Desserts
When you go to create a new post, WordPress will automatically file it under the default "Uncategorized" category until you assign it to one or more relevant categories. It‘s a good practice to put every post into at least one category.
Tip: Give your categories descriptive names that clearly indicate what type of content will be found there. Avoid generic category names like "Stuff" or "Miscellaneous".
Tags
If categories are your site‘s table of contents, tags are more like the index words. Tags are meant to describe the specific topics and details discussed in an individual post.
Unlike categories, tags are not hierarchical – you can‘t create "subtags". But an individual post can (and should) have multiple tags as relevant.
Sticking with our food blog example from before, if you wrote a post filed under Recipes > Breakfast, relevant tags might be:
- pancakes
- maple syrup
- weekend brunch
- kid-friendly
Think of tags like the hashtags you would add to a social media post. They help users find other content related to the subjects they are interested in. Used effectively, tags create a better experience for readers while organizing your content in a more granular, cross-referenced way.
Managing Taxonomies in WordPress
WordPress makes it easy to create and manage your categories and tags right from the admin dashboard. In the left-hand menu, look for the Posts section. Underneath that you‘ll see separate menu items for Categories and Tags.
Clicking into either of those will take you to a screen where you can view, edit, add and delete terms in that taxonomy. You‘ll be able to set the name, slug, description, and for categories, assign a parent category to create a hierarchy.
When writing an individual post, the Document settings in the right-hand sidebar has panels where you can assign categories and tags to the post you‘re editing. You can select from existing categories/tags or create new ones on the fly.
The SEO Benefits of Taxonomies
In addition to making your site easier to navigate for human visitors, taxonomies also send valuable signals to search engines about how your content is organized and what it is about. This helps search engines like Google understand and rank your content better.
Here are a few of the SEO benefits of well-structured taxonomies:
- They create a clear content hierarchy and site architecture
- The names and descriptions of your taxonomies have valuable keywords
- Taxonomies automatically generate archive pages that can rank for relevant terms
- They allow you to avoid "orphaned" posts that aren‘t linked to from anywhere else on your site
- In general, they help search engine crawlers discover and understand your content
To get the maximum SEO value from your categories and tags:
- Use clear, descriptive names
- Add keyword-rich descriptions where relevant
- Avoid "keyword stuffing" or adding irrelevant tags just to target different keywords
- Use a reasonable number of taxonomies – if everything is a special snowflake category, the groupings lose their meaning and usefulness
- Assign at least one category to every post
Custom Taxonomies
In addition to the default categories and tags, WordPress also allows you to create your own custom taxonomies. Custom taxonomies are a powerful way to sort and filter custom post types.
For example, if you created a custom post type for Events, you might want custom taxonomies for:
- Event Type (Conference, Seminar, Webinar, etc.)
- Industry/Niche
- Location
Some popular plugins that add custom post types, like WooCommerce for e-commerce, will automatically register custom taxonomies as well. For instance, WooCommerce creates a "Products" post type and "Product Categories" taxonomy.
You can create your own custom taxonomies via a plugin or by adding the appropriate code to your theme‘s functions.php file. The arguments when registering a taxonomy allow you to set:
- The name and labels
- Whether it is hierarchical (categories-style) or not (tags-style)
- What post types it can be used with
- The REST API availability
- The admin UI labels and visibility
Here‘s an example of the code to register a custom hierarchical "Genres" taxonomy that can be used with both the built-in Posts post type and a custom "Books" post type:
function wpb_register_taxonomy_genres() {
$labels = array(
‘name‘ => _x( ‘Genres‘, ‘taxonomy general name‘ ),
‘singular_name‘ => _x( ‘Genre‘, ‘taxonomy singular name‘ ),
‘search_items‘ => __( ‘Search Genres‘ ),
‘all_items‘ => __( ‘All Genres‘ ),
‘parent_item‘ => __( ‘Parent Genre‘ ),
‘parent_item_colon‘ => __( ‘Parent Genre:‘ ),
‘edit_item‘ => __( ‘Edit Genre‘ ),
‘update_item‘ => __( ‘Update Genre‘ ),
‘add_new_item‘ => __( ‘Add New Genre‘ ),
‘new_item_name‘ => __( ‘New Genre Name‘ ),
‘menu_name‘ => __( ‘Genre‘ ),
);
$args = array(
‘hierarchical‘ => true,
‘labels‘ => $labels,
‘show_ui‘ => true,
‘show_admin_column‘ => true,
‘query_var‘ => true,
‘rewrite‘ => [ ‘slug‘ => ‘genre‘ ],
);
register_taxonomy( ‘genre‘, [ ‘post‘, ‘book‘ ], $args );
}
add_action( ‘init‘, ‘wpb_register_taxonomy_genres‘ );With that in place, you would be able to assign Genre terms to both regular posts and book custom post type entries, if those existed. You can easily create custom template files in your theme like taxonomy-genre.php to control how genre archive pages look.
Best Practices for Using Taxonomies
To summarize, here are some key best practices to keep in mind when using taxonomies on your WordPress site:
- Put every post in at least one category
- Use tags for describing micro-topics and important keywords
- Choose clear, descriptive names for your taxonomies and terms
- Add descriptions to your taxonomies and terms where appropriate
- Utilize custom taxonomies for better organization of custom post types
- Avoid "over-tagging" – assigning too many irrelevant tags to a post
- Use a small number of high-level categories to keep your site architecture clean
By following these guidelines and taking full advantage of the built-in category and tagging systems in WordPress, you‘ll create a better organized site that‘s easier to navigate for both users and search engines alike. Taxonomies are a powerful tool, so use them wisely!
