When a post is in several categories, Yoast SEO and Rank Math let you mark one of them as the primary category. That choice decides which category appears in breadcrumbs and, with a %category% permalink structure, in the post URL. Both plugins store the primary category as a term ID. Term IDs differ from site to site, so after a move the setting can point to a different category or to nothing. With Import Export by RockStarLab, the primary category travels as the category slug and is matched to the same category on the receiving site.
Free: post export and import with SEO columns are in the free plugin. The test below used Import Export by RockStarLab 2.2.13 and Yoast SEO 28.8.
Short Answer
Export the posts with the Categories column and the Primary Category column from the Yoast SEO field group. The Primary Category column contains the category slug, for example coffee-origins. Import the file on the other site with both columns mapped. The import assigns the categories first, then finds the primary category by slug and saves this site’s term ID for it.
Export the posts with their primary category
In the plugin’s Export, we chose Blog Posts. On the Filters step we added a Taxonomy Filter for the categories brewing-guides, coffee-origins and roasting-notes, which left three posts. On the Fields step we dragged in Title, Slug, Content, Date, Categories and, from the Yoast SEO group, Primary Category:

We exported to CSV. The Primary Category column held the slug of each post’s primary category:
| post_title | Categories | _yoast_wpseo_primary_category |
|---|---|---|
| Ethiopia Guji Natural: Brewing Notes | Brewing Guides, Coffee Origins | coffee-origins |
| How to Dial In a V60 for Light Roasts | Brewing Guides, Roasting Notes | brewing-guides |
| Kenya AA Roast Profile | Coffee Origins, Roasting Notes | roasting-notes |
The table shows the category names; the Categories column in the file is longer, because it carries each category’s name, slug, description and parent. Categories that don’t exist on the receiving site are created with the same slugs.
Import on the other site
On the receiving site, we chose Blog Posts in Import, uploaded the CSV and clicked Auto Map. All six columns were mapped to the fields with the same names, including _yoast_wpseo_primary_category:

We kept the default options: match existing posts by slug, update matches, create the rest. The receiving site didn’t have these posts yet, so all three were created:

In the block editor of Ethiopia Guji Natural: Brewing Notes on the receiving site, both categories were checked and Yoast’s Select the primary category showed Coffee Origins, the same as on the source site:

The term IDs were different: Coffee Origins had ID 1659 on the source site and 386 on the receiving site. The import saved 386.
Change primary categories in a spreadsheet
The same column works for bulk changes on one site. Export the posts with Slug, Title and Primary Category, change the values, and import the file back with Check for Existing Items by Field set to Slug and Update. The cell can hold:
- the category slug, such as
roasting-notes; - the category name, such as
Brewing Guides; - a term ID of this site, as in files from older exports.
The primary category must be one of the post’s categories. If the cell names a category the post doesn’t have, the post keeps its current primary category; add the category in the Categories column of the same file to change both at once. An empty cell removes the primary category, and Yoast falls back to its default choice.
Things to know
- Rank Math works the same way: map the
rank_math_primary_categorycolumn. - Product categories have their own column,
_yoast_wpseo_primary_product_cat, in the product export. - The Post Meta (JSON) column, which carries all custom fields of a post, also keeps the primary category: the export adds the slugs, and the import points the setting at the right category.
- If the two sites are connected with Content Sync, a pushed post gets the primary category of the receiving site’s matching category without a file; see the sync and migration guides.
- Yoast rebuilds its own SEO data of each imported post after the import, so breadcrumbs use the new primary category without re-saving the posts.
Before importing, back up the site, or ask your AI agent to start the backup.
With an AI agent
Import Export by RockStarLab gives AI agents its exports, imports and Content Sync as abilities. Through the WordPress MCP Adapter, WordPress itself offers an agent only read-only abilities for site, user and environment information, so without the plugin the agent cannot do the steps above (to connect an agent, see connecting Claude Code to WordPress). With it, one request is enough:
With Import Export by RockStarLab, show the categories and the Yoast primary category of the posts in Coffee Origins.
In our run, the agent called rsl-ie/export-preview for posts with a tax_query on the category coffee-origins and the fields title, category names and _yoast_wpseo_primary_category. It returned two posts: Ethiopia Guji Natural: Brewing Notes with the primary category coffee-origins, and Kenya AA Roast Profile with roasting-notes.
FAQ
Why does the primary category change after moving posts to another site?
Yoast SEO and Rank Math store the primary category as a term ID. The same category has a different ID on another site, so a copied ID points to another category or to none.
How do I keep the Yoast primary category when importing posts?
Export the Categories and Primary Category columns together and map both in the import. The Primary Category column holds the slug, and the import saves the matching category of the receiving site.
Can I set the primary category for many posts at once?
Yes. Export Slug, Title and Primary Category, put a category slug or name in each row, and import the file with matching by Slug and Update.
Does this work with Rank Math?
Yes. Rank Math keeps the primary category in rank_math_primary_category, and the import resolves it the same way.
Related Guides
- Export and Import Yoast SEO of Categories and Tags with CSV
- How to Bulk Update Yoast SEO Titles and Meta Descriptions from CSV
- How to Bulk Update Existing WordPress Posts without Creating Duplicates
- Find All Noindex Posts in Yoast SEO and Review Them in a Spreadsheet
Get the free plugin on WordPress.org.

Comments 0
Have a question or a tip to share? Leave it below.