Asset 20 8 2
Does AI recommend your business? Run the free check →

Join 15,000 business owners, marketers and entrepreneurs. The Sunday newsletter you'll be annoyed only arrives once a week.

Article

How to Create a Custom Taxonomy in WordPress With Code

Register a custom taxonomy in code: hook a function to the init action, build labels and arguments arrays, and call register_taxonomy() with a taxonomy name, the post types it applies to and the arguments. Put it in a small plugin or your theme, then activate it and check the new meta box under Posts, Add New.

When Categories and Tags aren't enough

Categories and Tags work for a blog. But if you run a cooking site, a training business or a directory, you'll want to group content by something more specific, such as Courses, Ingredients or Locations. A custom taxonomy gives you that. WordPress describes it as a more structured alternative to Categories and Tags: you can reference these groups independently, and each gets its own menu in the admin area.

Hierarchical or flat: decide first

SettingBehaves likeGood for
hierarchical => trueCategories, with parents and childrenCourses, with modules under each one
hierarchical => falseTags, a flat listIngredients or skills

By default, category-style labels are used for hierarchical taxonomies and tag-style labels for flat ones, so the admin screens match the choice.

Registering the taxonomy

1. Choose where the code lives

The code can live in its own plugin, in your theme, or in an existing plugin. A small plugin keeps the taxonomy working if you change themes, which is why I'd use one.

2. Build the labels and arguments

A labels array holds the text shown in the admin, such as name, singular_name, search_items, all_items and add_new_item. An args array holds the configuration. WordPress's own example registers a hierarchical taxonomy called course for posts, with show_ui, show_admin_column, query_var and a rewrite slug.

3. Call register_taxonomy() on init

  • Write a function, for example wporg_register_course, that builds the labels and args arrays.
  • Inside it, call register_taxonomy() with the name course, the post types it applies to (here, post) and the args.
  • Set hierarchical to true, show_ui and show_admin_column to true, query_var to true, a rewrite slug of course, and show_in_rest to true.
  • Below the function, hook it with add_action on init so WordPress runs it at the right moment.

That's the whole pattern. You don't need a separate file for each taxonomy; one function can register several, though one per function is easier to read later.

The function must be hooked to the init action; register_taxonomy() shouldn't run before init. Setting show_in_rest to true includes the taxonomy in the REST API, which the block editor relies on.

4. Activate and check

Activate the plugin, then go to Posts > Add New. You should see a new Courses meta box beside the editor. If you set show_admin_column, the taxonomy also appears as a column in the posts list.

Naming rules that break registrations

WordPress Developer Resources flag the problems that stop a taxonomy appearing. The name can't be longer than 32 characters and may only contain lowercase letters, numbers, dashes and underscores. And it must not clash with other taxonomies, post types or reserved WordPress query variables. Calling register_taxonomy() too early, before init, means nothing registers at all. If your meta box doesn't appear, check those three things before anything else.

A short, prefixed name such as acme_course avoids most clashes, the same way a prefix protects a custom post type key.

Using the taxonomy on your site

Once it's registered, add terms from its own admin menu, then assign them as you write. With a rewrite slug, each term gets its own archive page, which can be a useful landing page for search. My guide to improving SEO on a WordPress site covers how to make those archives work for you, and my list of WordPress plugins worth installing covers the tools around it.

How Webflow and Shopify structure content

Webflow uses Collections: structured containers for dynamic content, similar to database tables, with fields that can reference other collections.

Work with me

Want AI doing the heavy lifting in your marketing?

I build the systems that handle the boring 80 percent, so you get your week back. Done properly, with the human kept in.

Shopify product pages can store custom information in metafields. For a platform comparison, see my piece on Webflow and WordPress.

My advice before you register one

Decide hierarchical or flat first, pick a short prefixed name, and put the code in a small plugin. Set show_in_rest so the block editor can use it, and check the meta box straight after activating. One well-planned taxonomy beats three overlapping ones.

A worked example: a training business with Courses as a hierarchical taxonomy can put 'SEO basics' at the top level and individual modules beneath it. Each lesson post is ticked into its module, and the Courses archive becomes a ready-made index of what's on offer. If you'd later want Skills as a flat tag-style list, that's a second, separate taxonomy, and it won't interfere with the first.

Want your tool on this list? Featured spots and reviews here are paid partnerships. Here's how to partner with me.

Frequently asked questions

How do I add a custom taxonomy in WordPress?

Call register_taxonomy() from a function hooked to init, in a plugin or theme.

Is there a character limit on the name?

Yes, 32 characters, using lowercase letters, numbers, dashes and underscores.

How's it different from categories?

Custom taxonomies are referenced independently and get their own admin menus.

Hierarchical or not?

Hierarchical behaves like Categories, non-hierarchical like Tags.

Does it work with the REST API?

Set show_in_rest to include it.

Published and maintained by the Lilach Bullock team, covering marketing, AI and business growth.
Your buyers are asking AI who to use. Does it say you?

See for free whether ChatGPT, Claude, Perplexity, Gemini and Google name you, and get the plan to become the answer.

Check my AI visibility →
Sundays only

Get the Sunday newsletter.

One email a week. AI experiments, marketing tactics, and the workflows Lilach is building right now in her own business.

Subscribe free

Let’s get your marketing running on AI.

Book a free 30-minute call

We figure out what you need, where AI fits in, and what working together would look like.

Book the call →

Or take the 30-second calculator

You’ll see the hours and the money quietly leaking out of your week, and the three workflows worth building first.

Take the calculator →

Or grab the free AI resource library

Prompt packs, templates, checklists, and swipe files. The exact tools I build for paying clients. Yours, free.

Get the library →
Keep reading

More from the blog.