Overview
WordPress uses something called a WXR (WordPress eXtended RSS) file to import and export site content. This article shows how to import and export this file in the panel and using WP CLI.
Importing
Exporting
Importing your site's XML data in the dashboard
The following steps import your site from an XML file.
- Log into your WordPress site at example.com/wp-login.php.
- Navigate to the Tools > Import page on the left menu.
- 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.
Importing a WXR file using WP-CLI
If you have a WXR file, you can import it using the 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 main site 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 your site's XML data in the dashboard
The following steps export your site as an XML file.
- Log into your WordPress site at example.com/wp-login.php.
- 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.
Exporting WXR file using WP-CLI
You can export your site data using the wp export command. View the following page for a full list of options you can use with this command.
The following command downloads all data from your site.
- 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.