WP AI Agent
Features Pricing Blog Contact Download Plugin Manage Subscription Get Free Key →

How to Import and Export WordPress Content: A Complete Guide

· · 9 min read

Knowing how to import and export WordPress content is one of the most valuable skills any site owner or developer can have — whether you are migrating to a new host, backing up your data, or moving content between staging and production environments. This comprehensive guide walks you through every method available, from WordPress's built-in importer and exporter to WP-CLI commands and third-party plugins.

Understanding WordPress Import and Export Basics

Before diving into the steps, it helps to understand what WordPress can export and import by default. The native WordPress tools work with an XML-based file format called WXR (WordPress eXtended RSS). This file contains your posts, pages, custom post types, comments, categories, tags, and basic user data.

What Is a WXR File?

A WXR file is essentially an RSS feed with WordPress-specific extensions. It stores your content in a structured, portable format that any WordPress installation can read. However, it does not include your theme files, plugin files, or the WordPress database itself — for a full site migration you will need additional tools covered later in this article.

When Should You Use Import and Export?

  • Moving a blog from one WordPress installation to another
  • Duplicating content from a staging site to a live site
  • Creating a content backup before a major update
  • Merging two WordPress sites into one
  • Migrating from WordPress.com to a self-hosted WordPress.org site

How to Export WordPress Content Using the Built-In Tool

WordPress ships with a built-in export tool that requires no plugins. It is the quickest way to grab your content in a portable WXR file.

Exporting All Content

  1. Log in to your WordPress admin dashboard.
  2. Navigate to Tools > Export in the left-hand menu.
  3. Select All Content to include posts, pages, custom post types, comments, and taxonomy terms.
  4. Click the Download Export File button.
  5. Save the generated .xml file to a safe location on your computer.

Exporting Specific Content Types

If you only need a subset of your content, WordPress lets you filter the export by content type, author, date range, status, and category. This is useful when you want to move only your published blog posts without pulling in draft pages or custom post type data.

  1. Go to Tools > Export.
  2. Choose a specific content type, such as Posts or Pages.
  3. Use the dropdown filters to narrow by author, category, start date, end date, and status.
  4. Click Download Export File when you are satisfied with the selection.

How to Import WordPress Content Using the Built-In Importer

Importing content into WordPress requires the WordPress Importer plugin, which is maintained by the WordPress core team and available free from the plugin repository. The import screen will prompt you to install it automatically if it is not already installed.

Installing the WordPress Importer

  1. In your destination WordPress site, go to Tools > Import.
  2. Find the WordPress entry in the list and click Install Now.
  3. Once installed, click Run Importer.

Importing Your WXR File

  1. On the importer screen, click Choose File and select the .xml file you exported earlier.
  2. Click Upload file and import.
  3. On the next screen, assign the imported authors to existing users on your site or create new users as needed.
  4. Check the box labelled Download and import file attachments if you want WordPress to attempt to pull in images and media from the source site.
  5. Click Submit to begin the import process.
  6. Wait for the process to complete. Large sites may take several minutes.

Troubleshooting Common Import Errors

Large WXR files sometimes hit PHP memory or upload size limits. If your import fails, try these fixes:

  • Increase upload_max_filesize and post_max_size in your php.ini file.
  • Split the export file into smaller chunks by exporting by date range.
  • Use WP-CLI (covered in the next section) for large imports without browser timeouts.

Using WP-CLI to Import and Export WordPress Content

WP-CLI is the official command-line interface for WordPress. It is the most reliable method for handling large sites, automated workflows, and server-to-server migrations because it bypasses PHP memory limits and browser timeouts entirely.

Exporting Content with WP-CLI

The following command exports all WordPress content to a WXR file named export.xml in the current directory:

# Export all content to a WXR file
wp export --dir=/path/to/export/folder --filename_format=export.xml

# Export only published posts from a specific author
wp export --post_type=post --post_status=publish --author=johndoe --dir=/path/to/export/folder

Importing Content with WP-CLI

  1. SSH into your server and navigate to your WordPress root directory.
  2. Make sure the WordPress Importer plugin is installed: wp plugin install wordpress-importer --activate
  3. Run the import command, replacing the path with the location of your WXR file:
# Import a WXR file and fetch remote attachments
wp import /path/to/export.xml --authors=create

# Import without downloading attachments
wp import /path/to/export.xml --authors=skip --skip=attachment

The --authors=create flag automatically creates new user accounts for any authors found in the import file. Use --authors=mapping.csv to map imported authors to existing users via a CSV file for more control.

Migrating a Full WordPress Site (Database + Files)

When you need to move an entire WordPress site — including themes, plugins, uploads, and the full database — a WXR export is not enough. You need a complete migration approach. The two most popular methods are using a dedicated migration plugin or performing a manual database and file transfer.

Using a Migration Plugin

Plugins such as All-in-One WP Migration, Duplicator, and Migrate Guru package your entire site into a single archive file that can be imported on the destination server with a few clicks. These tools handle serialized data in the database and automatically update URLs during migration.

  1. Install your chosen migration plugin on the source site.
  2. Run the export or backup function to generate the migration package.
  3. Install the same plugin on the destination site.
  4. Use the plugin's import function to upload and restore the package.
  5. Update your domain name and permalink settings if you moved to a different URL.

Manual Database Export and Import

For developers who prefer direct control, you can export the database using phpMyAdmin or mysqldump, then perform a search-and-replace on the old domain before importing it into the new server's database.

# Export the database using mysqldump
mysqldump -u db_user -p db_name > wordpress_backup.sql

# Use WP-CLI search-replace to update URLs after import
wp search-replace 'https://old-domain.com' 'https://new-domain.com' --all-tables

After importing the database, update the siteurl and home values in wp-config.php or in the wp_options table to match the new domain. You can also define them directly in wp-config.php:

// Add these lines to wp-config.php to override database URL values
define( 'WP_HOME', 'https://new-domain.com' );
define( 'WP_SITEURL', 'https://new-domain.com' );

Best Practices for WordPress Import and Export

Following a few key best practices will save you time and prevent data loss during content migrations.

Always Back Up Before Importing

Before running any import on a live site, create a full backup of both the database and the file system. Even a minor import error can overwrite or duplicate critical content. Use a plugin like UpdraftPlus or a hosting-level snapshot to protect your data.

Test on a Staging Site First

Run your import on a staging environment before touching production. This lets you verify that all content, images, and metadata transferred correctly without risking your live site.

Check Permalinks After Importing

After every import, go to Settings > Permalinks and click Save Changes without making any modifications. This flushes the rewrite rules and resolves the most common cause of 404 errors on newly imported content.

Verify Media Attachments

The WordPress importer downloads media files from the source site's URL. If the source site is offline or behind authentication, attachments will not transfer. In that case, manually copy the wp-content/uploads folder via FTP or rsync and then run a WP-CLI media regenerate command:

# Regenerate all thumbnail sizes after copying uploads manually
wp media regenerate --yes

Frequently Asked Questions

What is the difference between exporting WordPress content and migrating a WordPress site?

Exporting WordPress content using the built-in tool creates a WXR XML file that contains only your posts, pages, comments, and taxonomy data — it does not include theme files, plugin files, or the full database. Migrating a full WordPress site means moving all of these components together, typically using a migration plugin or a manual database and file transfer process.

Why are my images missing after importing a WordPress XML file?

The WordPress importer tries to download images from the source site's URL during import. If the source site is no longer accessible, if the URL has changed, or if the importer times out on a large media library, images will not be transferred. The fix is to manually copy the wp-content/uploads folder to the destination server via FTP or rsync and then regenerate thumbnails using WP-CLI.

Is there a file size limit for WordPress XML imports?

Yes. The built-in importer is subject to PHP's upload_max_filesize and post_max_size limits, which are often set to 8 MB or 64 MB by default on shared hosting. For large export files, increase these limits in your php.ini, split the export into smaller date-range files, or use WP-CLI to import directly on the server without any upload size restriction.

Can I import content from another CMS into WordPress?

Yes. WordPress includes built-in importers for Blogger, LiveJournal, Movable Type, TypePad, and Tumblr, all accessible under Tools > Import. For other platforms such as Drupal, Joomla, or Ghost, you will need a third-party plugin or a custom migration script that converts the source platform's export format into a WXR-compatible XML file.

Mastering how to import and export WordPress content gives you full control over your site's data, whether you are consolidating blogs, switching hosts, or building automated content pipelines. For those who prefer a hands-free approach, WP AI Agent is a powerful tool that lets you manage WordPress tasks like importing content, updating settings, and running migrations through a simple natural-language AI chat interface — no command line or manual steps required.

Ready to manage WordPress with AI?

Get 100,000 tokens free every month. No credit card required.

Get Your Free License Key →

More from the blog