How To Migrate a WordPress Blog

By Monday, November 10, 2014 2 , Permalink 1

One of things I love about WordPress it that it’s an open content platform. Being open, the platform understands that the user owns the content within. Truly owning your content means you should be able to take it out of the platform, and do whatever you want with it. WordPress makes it easy!

This post is a how-to guide on migrating a WordPress site. It covers:

  1. Exporting all your content from a hosted site.
  2. Importing the content to a self hosted WordPress site.

The export part applies also to self-hosted WordPress sites. I write specifically about a site because this is what I use for the example.

Being an open content platforms means you are in control of your data.

WordPress content export

You can also visit the support article on content export.

WordPress supports exporting posts, pages, comments, navigation menus, and terms (e.g. categories and tags). This kind of export does not include media items, themes, plugins, settings and configuration.

Start by logging in to your admin dashboard. Go to Tools -> Export:

The version offers a paid “guided transfer” option, which I don’t cover. Choose the free “export” option to proceed. This is what you will usually find with self-hosted sites.

The next (and final) screen allows you to choose what to export. In most cases you’d probably want to export everything you can.

You may have special reasons to export partial archives by applying the available filters. You can filter by content types, as shown above. Other types offer more fine-grained filters. For example, you could export posts in a date range, or by certain authors. One reason you might want to do that is if you want to reduce the size of the XML file. Another reason might be a scenario of multi-part incremental migration.

After choosing what to export, click the Download Export File to download the XML file with the chosen content.

WordPress content import

The WordPress Codex has an article on importing content into WordPress. It has a section for WordPress export file.

At the destination WordPress site, log in to your admin dashboard. Go to Tools -> Import:

Choose WordPress as the import source:

If you don’t have the WordPress Importer plugin installed, you will be prompted to install it:

Then Activate the plugin and resume running the importer:

If you already had the plugin installed, you’ll get straight to the importer screen:

Open the Choose File dialog, and navigate to the XML export file from the previous section:

Back at the importer screen, click Upload file and import to proceed.

The importer asks to map the authors it sees in the uploaded XML to existing or new authors in the current site:

Before clicking submit to confirm the import, take a moment to decide whether you want the importer to download and import file attachments.

As mentioned above, the XML export file does not include media items and file attachments. If your content refers to such files (by embedding an image for example), the references to these files use the full URL to the old site. If your old site is still online, the references will be valid. If you don’t choose to download and import file attachments, the importer will not touch these references. They will remain valid while the old site is online, and will break once the old site goes down. If that happens, you will need to fix it somehow. Usually by copying the upload directory from the old site (assuming you have access to it) to the new site, and updating the references in the database (or manually).

If this doesn’t sound like loads of fun to you, consider choosing to download and import file attachments before proceeding! If you choose this option, the importer will search for references to file attachments in your content. For every reference, the importer will try to download the file from the old site, upload it to the new site, and update the reference.

Why wouldn’t you want to enable this helpful feature?? Here are some reasons:

  1. You can’t. The old site is long gone. You’re migrating from backup.
  2. You have no reason to. You’re restoring a site from backup, without changing the domain name or directory layout. The “old references” are the same as the “new references”.
  3. You’re just testing things out. Downloading and importing hundreds, thousands, or more file attachments will take waaaaay too long, and it’s not important right now.
  4. Similar to the last one – it will take so long, that you rather use some other methods to transfer the uploads directory and fix the references in the database.
  5. You know you don’t have references to file attachments in your content. Maybe you don’t use file attachments. Or maybe you use some other method to manage them. Like I do.

Whatever your situation may be – choose wisely!

If you go down the path of manual transfer and database update, check out the database search and replace PHP script. I never used it, so I can’t vouch for it, but it is mentioned in the WordPress Codex article on moving WordPress.

The WordPress Importer can fetch and import file attachments from an old site – if it’s online

Click Submit to perform the import:

You may also see messages on failed imports. Review them and fix things if necessary. As the importer kindly reminds – remember to update the passwords and roles of imported users (if you created new ones of course).

Import caveats

Examining one of the imported posts reveals some disturbing things:

I know I chose not to fix file attachments, but I did expect that internal links will be fixed! I don’t know if this happens only in my setup for some reason, or it’s a known behavior. I can’t imagine when this behavior is desired. I don’t even understand why the WordPress editor produces absolute links instead of WordPress-relative ones. If you have an idea, please post it in the comments!

The WordPress importer, at least for me, leaves absolute post links with the URLs of the old site šŸ™

This can be fixed by searching for “” in the database, and replacing it with the new domain name. I skipped it, because during my migration I also changed the way I cross-link.

Another option is to edit the XML export file. It’s XML after all. That’s another thing I didn’t do. šŸ™‚


This article walked through exporting content from an existing WordPress site, and importing a WordPress export file into a new WordPress site.

I used a site for the export part, but it is essentially the same for self-hosted sites.

After reading this post, you should be comfortable with using the Export and Import features in WordPress. You should understand what content can be migrated this way, and what cannot. You should be aware of possible solutions for transferring file attachments, and possible caveats with the import process.

Feel free to ask questions or add your own tips and tricks in the comments!

  • Paulo Werdana
    December 4, 2014

    Well done job! Many thanks! Your post is very useful, though a bit expert-oriented, I’d say. Since Iā€™m not very tech savvy person, I searched for a solution that can do the job for me. My search ended when I found cms2cms converter. Worked very seamlessly – all my WordPress pages are now working as they should.

    • Itamar Ostricher
      December 4, 2014

      Thanks Paulo!
      I’m glad you could find a solution that worked for you!

Leave a Reply