What is a primary category?

A primary category is a per-post choice: of all the categories this post is filed under, which one speaks for it? The question only arises for posts in more than one category, and only in places with room for a single answer, such as the address of the post, its breadcrumbs and the section named in its structured data.

WordPress has no built-in primary category. The idea comes from plugins, and the setting usually appears in the editor next to the category checklist.

How it works

Left alone, each part of a site settles the question differently. For a permalink structure that includes %category%, WordPress core takes the post's category with the lowest ID, meaning the oldest one, and adds its parents. Breadcrumb code in a theme may take the first alphabetically or the deepest in the hierarchy. Markup generators make a third choice. The three can disagree.

A primary category setting stores one category ID with the post and hands it to all of them. The post stays in its other categories and still shows in their archives. Only the representative changes.

Example

A post is filed under Dinner (ID 3) and Vegetarian (ID 12), and the permalink structure is /%category%/%postname%/.

  • By default the address is /dinner/lentil-ragu/, because 3 is lower than 12.
  • With Vegetarian as the primary category it becomes /vegetarian/lentil-ragu/, and the breadcrumb reads Home › Vegetarian › Lentil ragu.

If the post was already published, the first address keeps loading, with a canonical tag pointing to the second. WordPress does not redirect it while the post is still in Dinner, so the choice is best made before publishing.

In WordPress

Developers can set the URL part with the post_link_category filter. Hydrogen SEO adds a Primary Category dropdown to the Categories panel in the block and Classic editors from version 0.0.30, shown when two or more categories are ticked, and applies the choice to permalinks, breadcrumbs, BreadcrumbList and Article schema, and WooCommerce product categories; see primary category.

Common mistakes

  • Changing it on old posts for neatness. With %category% permalinks that is a URL change, and the old address stays live as a second copy that only its canonical tag resolves.
  • Filing posts under many categories and relying on the primary one to sort it out. One category and a few tags is usually the cleaner structure.
  • Expecting a ranking boost. The gain is a URL, breadcrumb and markup that agree with each other.

Common questions

Does WordPress have a primary category setting?

Not in core. WordPress picks the category with the lowest ID for %category% permalinks. A primary category choice is added by SEO plugins or custom code.

Does the primary category affect SEO?

Indirectly. It makes the post's URL, breadcrumb trail and structured data name the same section, which you choose. Search engines have no separate primary category signal.