Documentation

Extracting a Subsite From Multisite to Create a New Single Site Install

NOTE: The following is a very manual process, we have since released Multisite Tools 1.1 with both Export Subsite as Single Site Install and Push Subsite to Single Site Install functionality.

Follow the steps below to convert a WordPress Multisite subsite into a standalone WordPress website.

Here are some of my environment details for context:

Multisite type subdomain (subdirectory also supported)
Site address http://dev.apple.com
Subsite address http://pie.dev.apple.com
Desired single site address http://dev.pie.com
Subsite table prefix wp_2_

Finding the Subsite Table Prefix

You’ll first need to find the table prefix of the subsite you’re looking to extract. Follow the steps below to find this information:

  1. Log into the WordPress network admin dashboard. (e.g. http://example.com/wp-admin/network)
  2. Click the “Sites” menu item, here you’ll be presented with a list of your subsites.
  3. Click the subsite you wish to extract.
  4. The address bar in your web browser will now contain the ID of your subsite, e.g. http://dev.apple.com/wp-admin/network/site-info.php?id=2

In the example above my subsite ID was “2”. See the formula below to calculate your subsite table prefix:

WordPress table prefix + subsite ID + underscore = subsite table prefix

Here’s what mine looked like in practice:

wp_ + 2 + _ = wp_2_

Export an SQL File

  1. Log into the WordPress network admin dashboard. (e.g. http://example.com/wp-admin/network)
  2. Navigate to the WP Migrate DB admin page, i.e. Settings → Migrate DB Pro.
  3. Ensure “Export File” is selected.
  4. In the Find & Replace section copy the contents of the URL find column into the URL replace column.
  5. Fill in the file path find & replace row as required (or remove it if not required).
  6. Click the “Add Row” button.
  7. Add the subsite address in the left column in the new find & replace row.
  8. Add the desired single site address in the right column in the new find & replace row.
  9. Here’s what my find & replace section looks like so far:find-replace
  10. If you are extracting anything other than the primary subsite and copying across your uploads directory (see “Copying Themes / Plugins / Uploads”) you may want to add another Find & Replace row to convert the subsite specific uploads paths, for example: “/uploads/sites/2/” => “/uploads/”.
  11. Expand the “tables” section and select the “Migrate only selected tables below” option.
  12. Select all the relevant subsite tables as well as the “users” and “usermeta” tables.tables
  13. Click the “Migrate DB” button, wait for the export to complete.
  14. Open the SQL file in your text editor of choice.
  15. Find and replace all instances of the multisite subsite table prefix with your new single site table prefix, e.g. “wp_2_” → “wp_”.
  16. Save and close the SQL file.
  17. Create a new database and import the SQL file.
  18. Run these SQL queries to remove duplicate usermeta rows. *
  19. Setup WordPress and point it to the new database.
  • WordPress multisite stores network specific usermeta and subsite specific usermeta for each user, these queries remove the duplicated data. Please note that the script assumes the later record is for the subsite, which might not always be the case. Please also note that the script assumes you’re using the default “wp_” table prefix, please update this value in the script if using a custom table prefix.

Copying Themes / Plugins / Uploads

See the diagram below illustrating which files to copy from your existing multisite installation to your new single site installation.

ms-content-migration

Removing Users

Step 11 above has you exporting the “users” and “usermeta” tables, this will export all users from the entire network.

You may want to head over to the “Users” page in your WordPress dashboard and remove any redundant or non-essential users from your site after you’ve completed the extraction.

If using WP e-Commerce, you may want to consider running this SQL script after you’ve imported the SQL file. The aforementioned script removes phantom users created by WP e-Commerce.

Done!

You have now successfully extracted a multisite subsite into a single WordPress installation.