Overview
This article explains how to import and export WordPress site content using an XML or WXR (WordPress eXtended RSS) file.
Importing content
The following steps show how to import an XML or WXR file into a WordPress site.
Import a site's XML data in the dashboard
- Log in to your WordPress site.
- Navigate to the Tools > Import page.
- Click the Run Importer link.
- Browse your computer for the XML file, then click Upload file and import.
- Choose if you'd like to create a new WordPress user for the import, or use an existing user.
- Click the Submit button.
An XML file is uploaded to your website.
Import a WXR file using WP-CLI
If you have a WXR file, you can import it using the WP CLI wp import command. This command uses the file, --authors, and --skip options which you can read about here.
In the following example:
- file is set to the name of the file you're importing. In this example it's my-wordpress-site.xml.
- --author is set to skip
- --skip is excluded from this example
- Upload your WXR file to your WordPress site using an FTP client. Make sure the XML file is in your website's directory.
- Log into your website via SSH.
- Run the following command to import the XML file.
[server]$ wp import my-wordpress-site.xml --authors=skip Error: WordPress Importer needs to be installed. Try 'wp plugin install wordpress-importer --activate'.
An error displays if you have not already installed the WordPress Importer plugin. If so, run the command mentioned to install it.
[server]$ wp plugin install wordpress-importer --activate
Once installed, run the import command again. If successful, you'll see the following message:
Success: Finished importing from 'my-wordpress-site.xml' file
Exporting content
The following steps show how to export a WordPress site to an XML or WXR file.
Export a site's XML data in the dashboard
- Log in to your WordPress site.
- Navigate to the Tools > Export page on the left menu.
- Select the radio button titled All Content.
- Click the Export button.
An XML file is downloaded to your computer.
Export a WXR file using WP-CLI
You can export all site data using the WP CLI wp export command. See this page for a full list of options you can use with this command.
- Log into your website via SSH.
- Navigate into your website's directory.
[server]$ cd ~/example.com
- Get the full file path to your current directory by running pwd.
[server]$ pwd /home/username/example.com
- Add your file path to the command below to export the XML file. Make sure to change username to your Shell user and example.com to your website.
[server]$ wp export --dir=/home/username/example.com Success: All done with export.
Your site data is downloaded into a file named something like sitename.wordpress.date.time.xml.