30 days free. No credit card. Full access from the moment you connect your site.

Start free trial

Get Rank Math Primary Term

rank-math/get-primary-term returns the Rank Math primary term for a post and taxonomy, along with every term the post has in that taxonomy, with the primary flagged.

The full list is there because a primary term the post does not have is ignored.

At a glance

Abilityrank-math/get-primary-term
ToolsetRank Math — toolset/rank-math
GroupRank Math › Content SEO
RequiresRank Math SEO, active on the site
Capabilitymanage_options
SafetyRead-only — changes nothing
RepeatableIdempotent — running it twice leaves the same result
Ships inAcrossAI Abilities Manager 0.0.34 and later

How it works

The primary term drives two visible things: the %category% segment of the permalink, on sites that use it, and the breadcrumb trail. Both are structural — they affect the URL and the internal linking, not just a label.

Rank Math stores the primary term as an ID and does not validate it against the post’s actual terms. Remove the term from the post and the stored ID remains, pointing at a term the post no longer has, and Rank Math quietly falls back to its default ordering.

That produces a breadcrumb that changed for no apparent reason and an admin screen still showing a primary term that is not in effect.

Returning the assigned list alongside makes both states visible and gives you a valid set to choose from before writing.

Input

NameTypeRequiredWhat it is
post_idintegerYesThe post ID.
taxonomystringYesThe taxonomy, for example category.

What comes back

NameTypeWhat it is
primary_termobjectThe stored primary term, if any.
assigned_termsarrayEvery term the post has in that taxonomy, primary flagged.
successbooleanWhether the call completed.
messagestringA one-line summary of what happened, suitable for showing a human.
error_codestringPresent only on failure — a stable machine-readable reason, such as a missing field, a wrong field type or an unmet confirmation.

Example

Ask your assistant:

What is the primary category on post 412?

It resolves to one call:

{
  "ability": "rank-math/get-primary-term",
  "parameters": {
    "post_id": 412,
    "taxonomy": "category"
  }
}

Worth knowing

  • A stored primary term the post no longer has is ignored, silently.
  • The primary term shapes the permalink on %category% sites and the breadcrumb trail everywhere.
  • Pick from the assigned list when writing.

Related abilities


Get the plugins:
AcrossAI Abilities Manager · AcrossAI MCP Manager

Browse the rest: Every ability, by category


Keep reading