Back to blog
4 min read Import Guides

Import Only Some Posts from a WordPress XML (WXR) Export File

A WordPress export file (Tools → Export) holds everything: all posts, pages, drafts and their categories. When you only want part of it on another site, for example the recipes of an old food and travel blog, the standard WordPress importer brings in all of it, and you delete the rest by hand. With Import Export by RockStarLab, you set conditions and only the matching posts are imported.

Free: everything here is in the free plugin. Use version 2.2.1 or newer: 2.2.0 adds the row filter and 2.2.1 keeps the tags of WordPress export files apart from the categories.

The export file

Our file is the export of a food and travel blog: 12 items, 10 posts and 2 pages. Six posts are in the Recipes category (one of them also in Travel), one recipe is still a draft, and the others are travel stories and news. We want only the published recipes, with their categories and tags.

In such a file every post is an <item>. The plugin reads each item as a row and its fields as columns: title, content:encoded, wp:post_date, wp:status, wp:post_type, category (the categories) and tag (the tags).

Step 1: Upload and Auto Map

Open Import Export → Import, choose Posts, upload the XML file and continue to the mapping step. Click Auto Map. The columns of WordPress export files are recognized: title, content, excerpt, date, slug, status, author, categories and tags:

Mapped fields of a WordPress export file: title, category, tag, dc:creator, content:encoded, excerpt:encoded, wp:post_date, wp:post_name
Auto Map recognizes the columns of a WordPress export file.

Step 2: Filter the rows

In step 5, Import Options, tick Filter Rows and add three conditions:

Filter Rows with category contains Recipes, wp:status equals publish and wp:post_type equals post
Only published recipe posts.
  • category contains Recipes: the post is in the Recipes category, alone or with others.
  • wp:status equals publish: leaves out drafts, pending and private posts.
  • wp:post_type equals post: leaves out pages, menu items and attachments, which the same file can contain.

Rows must match: all conditions means a row needs all three. Text comparisons ignore letter case.

Step 3: Import

Click Start Import. Our import created 6 posts in a second:

Import Completed Successfully with 6 created posts
Six of the twelve items were imported.

The job log says 6 rows did not match the row filter and were not imported: the travel and news posts, the draft recipe and the two pages.

The result

The six recipes are on the new site with their original dates, categories and tags. Market Day in Lyon keeps both its categories, Recipes and Travel:

Posts list with six recipe posts, their categories, tags and original dates
The recipes with their categories, tags and dates.

More filters

  • Posts after a date: wp:post_date greater than / after 2023-01-01.
  • One author: dc:creator equals the author’s login.
  • Several categories: set Rows must match to any condition and add one category contains condition per category.
  • Leave out a category: category does not contain News.
  • Tags: the tag column works the same way, for example tag contains baking.

Contains also matches parts of a name: Recipes matches a category called Vegan Recipes too. Use is one of with the exact names when that matters.

The import adds posts to the site. Back up the site first, or ask your AI agent to start the backup.

With an AI agent

An AI agent connected to the site through the WordPress MCP Adapter (see connecting Claude Code to WordPress) can do the same:

Without the plugin, WordPress 7.1.5 gives a connected agent only three read-only abilities for site, user and environment information. The exports, imports and syncs in the requests below are abilities of Import Export by RockStarLab.

With Import Export by RockStarLab, import only the published recipe posts from old-blog.xml, with their categories and tags.

In our run, the agent loaded the file with rsl-ie/upload-from-url, read the columns from the answer, and called rsl-ie/import-start with the mapping and options.row_filters: category contains Recipes, wp:status equals publish and wp:post_type equals post. Job 99 finished with 6 posts, and the log said that 6 rows did not match.

FAQ

Are images in the posts imported too?

Images in the post content are downloaded into the Media Library when Automatically Import Media Files is on in step 5 (the default) and the old site is still online. The file itself has only links.

Can I import the comments of these posts?

Not in the same step. The comment columns of the file (wp:comment/…) are not mapped to post fields. Import comments separately, or move the posts and comments between two live sites with Content Sync.

What if I run the import twice?

Set Check for Existing Items by Field to the slug (post_name) and If Match Found to Skip or Update, so the posts are not created twice.

Does the filter work with CSV and Excel files?

Yes. The Filter Rows option works with every file format; the columns are the column headers of the file.

Get the free plugin on WordPress.org.

Dmitriy
About author

Dmitriy

WordPress Developer with 15+ years of commercial experience. Elite Author on ThemeForest and creator of custom WordPress plugins. Passionate about clean code, performance optimization, and building useful tools for the WordPress community.

JOIN THE CONVERSATION

Comments 0

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

Leave a comment

Your email address will not be published. Required fields are marked *

We store your name, email and comment to show and moderate it; your email is never published. Spam protection is provided by Cloudflare Turnstile and profile pictures by Gravatar. See our Privacy Policy.


Try the plugin with no risks!

New users get 1 month with access to all premium features. Experience the most powerful WordPress data engine today.

Download Now
Get PRO for FREE