Import single WordPress site into WordPress MU Installation

Jun 1, 2014 07:05 · 315 words · 2 minute read

When you have a large number of blogs to look after, it can be a challenge to keep on top with security updates for plugins and WordPress Core. At the same time the bad guys are getting faster and faster to exploit these kinds of holes.

For that reason I like to keep all of my blogs in a WordPress Multisite installation. Sites share users, WordPress core and plugins and database. They still have their own database tables and upload folder.

Sometimes I start with a simple WordPress install because I’m not sure, how the site will later be used. After a site has consolidated I’m importing the content into my multisite installation for easier administration.

Here are some steps to follow, when doing this. I got some ideas from here but would like to share my experience to save someone else some time.

  1. Export the original site’s database tables. Skip the tables wp_users and wp_usermeta.
  2. Create a new, empty blog in your WordPress MU installation. Note the ID of the new site.
  3. Open the .sql file you got from step 1 and rename all the tables from wp_xxx to wp_ID_xxx. E.g. wp_options becomes wp_20_options.
  4. Find and replace all the file paths. /wp-content/uploads/2014/xx.jpg becomes /wp-content/uploads/ID/2014/xx.jpg
  5. Confirm you really renamed ALL the tables in the .sql file. You really want to avoid overwriting stuff in you MU installation.
  6. Import the old blog’s .sql into your WordPress MU database
  7. Navigate to wp_ID_options. Rename wp_user_roles to wp_ID_user_roles. This prevented me from adding new users.
  8. Copy plugins, themes and media files to WordPress MU. Generally files are uploaded to /wp-content/uploads/ID. If this folder doesn’t exists, just create it.

That’s it. After those steps, the blog should look exactly the same as before. You can continue by adding some users. If someting breaks, it might look ugly. Just keep a cool head and re-trace the steps to find the error.