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
| Ability | rank-math/get-primary-term |
| Toolset | Rank Math — toolset/rank-math |
| Group | Rank Math › Content SEO |
| Requires | Rank Math SEO, active on the site |
| Capability | manage_options |
| Safety | Read-only — changes nothing |
| Repeatable | Idempotent — running it twice leaves the same result |
| Ships in | AcrossAI 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
| Name | Type | Required | What it is |
|---|---|---|---|
post_id | integer | Yes | The post ID. |
taxonomy | string | Yes | The taxonomy, for example category. |
What comes back
| Name | Type | What it is |
|---|---|---|
primary_term | object | The stored primary term, if any. |
assigned_terms | array | Every term the post has in that taxonomy, primary flagged. |
success | boolean | Whether the call completed. |
message | string | A one-line summary of what happened, suitable for showing a human. |
error_code | string | Present 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
- Update Rank Math Primary Term — set or clear it
- Get Inbound Internal Links — breadcrumbs are internal links
Get the plugins:
AcrossAI Abilities Manager · AcrossAI MCP Manager
Browse the rest: Every ability, by category