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:
- Log into the WordPress network admin dashboard. (e.g. http://example.com/wp-admin/network)
- Click the “Sites” menu item, here you’ll be presented with a list of your subsites.
- Click the subsite you wish to extract.
- 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
- Log into the WordPress network admin dashboard. (e.g. http://example.com/wp-admin/network)
- Navigate to the WP Migrate DB admin page, i.e. Settings → Migrate DB Pro.
- Ensure “Export File” is selected.
- In the Find & Replace section copy the contents of the URL find column into the URL replace column.
- Fill in the file path find & replace row as required (or remove it if not required).
- Click the “Add Row” button.
- Add the subsite address in the left column in the new find & replace row.
- Add the desired single site address in the right column in the new find & replace row.
- Here’s what my find & replace section looks like so far:
- 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/”.
- Expand the “tables” section and select the “Migrate only selected tables below” option.
- Select all the relevant subsite tables as well as the “users” and “usermeta” tables.
- Click the “Migrate DB” button, wait for the export to complete.
- Open the SQL file in your text editor of choice.
- Find and replace all instances of the multisite subsite table prefix with your new single site table prefix, e.g. “wp_2_” → “wp_”.
- Save and close the SQL file.
- Create a new database and import the SQL file.
- Run these SQL queries to remove duplicate usermeta rows. *
- 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.
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.