Import & Export Overview
Overview
WP-CLI provides two powerful commands for moving WordPress content between sites: wp export generates a WXR (WordPress eXtended RSS) XML file, and wp import reads it back in. Together they power content migrations, staging syncs, and backup workflows.
When to Use XML Export vs Database Export
| Scenario | Use |
|---|---|
| Move posts/pages/media between sites | wp export / wp import |
| Full site migration (settings + everything) | wp db export / wp db import |
| Scheduled content backup | wp export (portable XML) |
| Environment clone (prod → staging) | wp db export |
Basic Workflow
# On the source site
wp export --dir=/tmp/exports --post_type=post
# Transfer file
scp /tmp/exports/*.xml user@destination:/tmp/
# On the destination site
wp import /tmp/export.xml --authors=create
Key Concepts
- WXR format — WordPress XML schema that includes posts, pages, comments, terms, and post meta.
- Authors mapping — When importing, you choose to
create,mapping.csv, orskipauthor matching. - Media —
wp exportdoes not export media files, only references. Media must be transferred separately.