Introduction to Taxonomies: Organizing WordPress Content
Learn to register custom taxonomies to categorize your WordPress Knowledge Base. Discover how to enable hierarchical features and link them to your CPT.
Previously in this course, we explored Configuring CPT Arguments: Mastering Knowledge Article Registration to define our core content structure. Now that we have our "Knowledge Article" CPT, we need a way to group and filter that content. This lesson introduces the taxonomy, the essential WordPress tool for content classification.
What is a Taxonomy?
In WordPress, a taxonomy is a mechanism for grouping posts together. Think of it as a labeling system. By default, WordPress provides two: Categories (hierarchical) and Tags (flat).
When building a Knowledge Base, you often need custom taxonomies—such as "Topic" or "Product Version"—to help users navigate your documentation. By registering a custom taxonomy, you move beyond simple lists and create a structured information architecture that makes your plugin professional and scalable.
Registering a Custom Taxonomy
To register a custom taxonomy, we use the register_taxonomy() function. Just like with Registering Custom Post Types: A WordPress Developer’s Guide, we hook this into the init action.
Here is how we implement it within our MVC structure. In your PluginCore class (or a dedicated TaxonomyManager class), add the following:
PHPpublic function register_knowledge_taxonomies() { $labels = [ 'name' => 'Topics', 'singular_name' => 'Topic', 'search_items' => 'Search Topics', 'all_items' => 'All Topics', 'edit_item' => 'Edit Topic', 'update_item' => 'Update Topic', 'add_new_item' => 'Add New Topic', 'new_item_name' => 'New Topic Name', 'menu_name' => 'Topics', ]; $args = [ 'hierarchical' => true, #6A9955">// Enables parent/child relationships 'labels' => $labels, 'show_ui' => true, 'show_admin_column' => true, 'query_var' => true, 'rewrite' => ['slug' => 'kb-topic'], ]; register_taxonomy('kb_topic', ['knowledge_article'], $args); }
Breaking Down the Arguments
hierarchical: When set totrue, your taxonomy behaves like categories (you can have parent and child topics). Setting it tofalsemakes it behave like tags.show_admin_column: This is a pro-tip. Setting this totrueautomatically adds a column to your Knowledge Article list table in the admin, allowing you to see and filter by topic at a glance.- The second parameter (
['knowledge_article']): This is crucial. It explicitly associates this taxonomy with our custom post type. If you leave this array empty, the taxonomy won't be attached to any post type by default.
Hands-on Exercise
- Open your plugin's main initialization file.
- Add an
add_action('init', [$this, 'register_knowledge_taxonomies']);line to your constructor. - Implement the method shown above.
- Navigate to your WordPress dashboard, refresh, and verify that "Topics" appears under your "Knowledge Articles" menu.
- Create two topics, one as a child of the other, to verify the hierarchical functionality.
Common Pitfalls
- Forgetting to Flush Permalinks: If you change the
rewriteslug, your taxonomy archives might return 404 errors. Simply visit Settings > Permalinks and click "Save Changes" to flush the rewrite rules. - Taxonomy Name Length: Keep your taxonomy slug short and avoid using reserved WordPress names (like
categoryorpost_tag).kb_topicis safe and descriptive. - Missing Post Type Association: If your taxonomy doesn't show up on the edit screen, double-check that the second argument of
register_taxonomyincludes your CPT slug exactly as defined in your registration function.
Recap
We’ve successfully introduced a classification layer to our Knowledge Base. By utilizing a hierarchical taxonomy, we’ve enabled nested content organization, which is vital for documentation plugins. You now know how to define labels, enable administrative visibility, and link these taxonomies to your CPT.
Up next: We will begin the process of capturing custom data for our articles by Designing Meta-Boxes.
Work with me

Custom WordPress Plugin Development
Custom WordPress & WooCommerce plugins built to standard — by the developer behind a plugin with 5,000+ active installs and a SaaS with 10,000+ users.

Headless WordPress + Next.js Frontend Development
Keep WordPress for content, get a lightning-fast Next.js frontend. The best of both worlds — familiar editing, modern speed.