Importing and exporting a WXR file in WordPress

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. 

  1. Log into your WordPress site at example.com/wp-login.php.
    wp export
  2. Navigate to the Tools > Import page.
    wp export
  3. Click the Run Importer link.
    wp export
  4. Browse your computer for the XML file, then click Upload file and import.
    wp export
  5. Choose if you'd like to create a new WordPress user for the import, or use an existing user.
  6. 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
  1. Upload your WXR file to your WordPress site using an FTP client. Make sure the XML file is in your main site directory.
  2. Log into your website via SSH.
  3. 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. 

  1. Log into your WordPress site at example.com/wp-login.php.
    wp export
  2. Navigate to the Tools > Export page.
    wp export
  3. Select the radio button titled All Content.
  4. 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.

  1. Log into your website via SSH.
  2. Get the full file path to your current directory by running pwd.
    [server]$ pwd
    /home/user/example.com
  3. Add your file path to the command below to export the XML file.
    [server]$ wp export --dir=/home/user/example.com
    Success: All done with export.

    Your site data is downloaded into a file named something like sitename.wordpress.date.time.xml.

Did this article answer your questions?

Article last updated PST.

Still not finding what you're looking for?