Migrating WordPress

presented at

WordPress DC Meetup Group

March 12, 2013

Slides Available at


Hi, I'm Russell Heimlich

WordPress sure is great…

  • Plugins

  • Themes

  • WYSIWYG Editing

The Rockstars of WordPress

So Import/Export is…

The Roadies of WordPress

What is a Roadie?

An individual who is responsible for setting up, tearing down, and generally maintaining the equipment for a band.

Without roadies, the rockstars can't perform at different venues.

Without an export you're content is stuck!

How Content is Stored within WordPress

The Database

  • Content (Post/Page Stuff, custom fields)

  • Comments

  • Terms and Relationships

  • Options/Widgets/Settings

The Main Folders

wp-content Holds Your Stuff!

Inside of wp-content

  • Uploads holds all of your uploaded files

Media are stored in the Uploads folder

But they are referenced by Posts stored in the database.

Any questions so far?

Why might I need Export/Import?

  • Changing Web Hosts
  • Moving from WordPress.com to your own WordPress site
  • Set-up a staging or development version of your site
  • Moving from some other CMS to WordPress

Where are the Export/Import features?

Under the Tools menu.


Getting stuff out of WordPress.

The Export Screen

WordPress eXtended RSS (WXR) File

An XML file that WordPress uses to import or export content.

via Codex: Tools Export Screen

A WXR File Includes

  • Posts, Pages, and Custom Post Types

  • Comments

  • Custom Fields

  • Categories, Tags, and Custom Taxonomies

  • Users

A WXR File Doesn't Include

  • Your Uploaded Media Files*

  • Most Options/Settings

  • Widgets

How can we migrate those things not included in the WXR file?

Uploaded Media Files

  1. Download them on import

  2. Copy your wp-content/uploads folder

Downloading Media Files on Import

Handy when it works but unreliable.

Copying the Uploads Folder

  • FTP into your server

  • Navigate to /wp-content

  • Download the Uploads folder to your computer

  • Might as well download the entire wp-content folder

Exporting Options/Settings

  • Lots of settings aren't exported

  • Some plugins offer setting import/export functionality

  • Document the settings and recreate them by hand

Exporting Widgets

There's a plugin for that!

via http://wordpress.org/extend/plugins/widget-settings-importexport/

WXR Export Can Fail

  • Too much stuff!

  • Export script can timeout

  • Server can run out of memory

Consider Exporting in Chunks

via http://wordpress.org/extend/plugins/advanced-export-for-wp-wpmu/

Straight Database Backup

If the WXR Export File doesn't work, you'll have to backup the database.


Plugin to export your database from within the WordPress admin.

via http://wordpress.org/extend/plugins/wp-dbmanager/

Sequel Pro (Mac only)

via sequelpro.com


via phpmyadmin.net


Getting stuff into WordPress.

“Built-in” Import Plugins

Variety of Other Import Plugins

Importing Your WXR File

  1. Upload the file

  2. Map users from the WXR file to users in your new site

  3. Import attachments?

  4. View your imported items

If you downloaded your Uploads folder…

Upload it to your new site so the media files are in place.


From another CMS to WordPress.

See if anyone has done the heavy lifting

  • Search the WordPress plugin repository for an importer

  • Search Google to see if anyone has done the same type of migration

Otherwise Prepare To Roll Your Own Solution

WARNING: This is Developer Territory

A database dump of the old site might be helpful…

but you'll probably be better off scraping the site instead!

Prep Work

  • What are the different pieces?

  • How does the content map to WordPress?

  • What custom functionality do you need?

  • How will the old content redirect to the new content?

  • What content can die?

Imagine the Post Editor

How do we scrape a site?

Set-up A Local Environment

Write a Script to Download and Parse Pages

  • simple_html_dom - Download HTML pages and parse them like jQuery.

  • cURL - For downloading images or other contnet.

Tips for your Scraping Script

  • Makes it modular

  • Use AJAX calls to prevent your PHP script from timing out

  • Store your data in a database so you can use it again later

Test, test, test!

It will take many runs to get it just right.

After You Have Scraped All of the HTML…


Make a backup of the old site, preferably easily accessible.

Helpful Tools

Plugins and resources that come in handy after a migration.

Cleaning Up with Search Regex

Replace references to your old domain to your new domain.

via http://wordpress.org/extend/plugins/search-regex/

Preview Your Search & Replaces

But be careful, there is no undo!

Pattern Match with Regular Expressions

via http://regex.larsolavtorvik.com/

Handle Redirects with Redirection

via http://wordpress.org/extend/plugins/redirection/

Add from Server Plugin

Import images via a folder on your server.

via http://wordpress.org/extend/plugins/add-from-server/

Link Monitoring Tools

To see what broke after a migration.

Broken Link Checker

via http://wordpress.org/extend/plugins/broken-link-checker/

Google Webmasters

via google.com/webmasters


Tweet me, @kingkool68, or contact me.