Recently, I needed to migrate a WordPress site from a Multisite installation to a Single Site .com
.
I usually use the WP Migrate DB plugin because it works well for my basic needs, but going through the Multisite -> Single Site transition very manually, sure made me see the value in the Pro version of their plugin.
For a full video tutorial walkthrough of the transfer process, I highly recommend Morten Rand-Hendricksen’s Lynda.com course on the subject. Below are a few step-by-step notes detailing the process.
Setting things up
- Setup your
<TARGET>
site first- Install WordPress with default options
- Migrate
plugins
,themes
, anduploads
- Move them from the
<ORIGIN>
site -> the<TARGET>
site * - Using FTP, I download what I want to keep to my Desktop
- Then, upload them back to the NEW site (watch a video, it’ll take a while)
- Move them from the
- Install
WP Migrate DB
on both sites and open it
Single Site -> Single Site
- From the
<TARGET>
site:- Copy the URL ->
<ORIGIN>
site’s “New URL” - Copy the file path ->
<ORIGIN>
site’s “New file path”
- Copy the URL ->
- On the
<ORIGIN>
site:- Export the SQL file
- Prepare
<TARGET>
site’swp-config.php
file **- Open
<ORIGIN>
site’swp-config.php
file - Find
$table_prefix
down in the file and copy that table prefix String - Replace
$table_prefix
String in the<TARGET>
site’swp-config.php
with the<ORIGIN>
site’s String - Save the modified
<TARGET>
site’swp-config.php
- Open
- Open
phpadmin
on the<TARGET>
site- Drop all
<TARGET>
site’s defaultwp_
tables - Import
<ORIGIN>
site’s SQL file (from WP Migrate DB)
- Drop all
Multisite -> Single Site
I did all the previous steps for the Multisite configuration (to test it), but ended up with the default site and not any of the Posts or content I needed in my subsite. Luckily, DeliciousBrains has written up a tutorial detailing this kind of migration as well:
Extracting a Subsite from Multisite to Create a New Single Site Install
These are the steps I followed (and some notes about mistakes I made):
Notes:
* Originally, when you want to move your uploads
folder from Multisite to a single site, you’ll notice another folder in the uploads
folder:
/uploads/sites/4/2016/
- The
sites
folder contains all the uploads for each subsite - The
4
(or other numbered folder) is the site ID (you can find the site ID by going to that particular site’s admin Page)http://sitename.com/wp-admin/network
-> Sites -> Subsite namehttp://sitename.com/wp-admin/network/site-info.php?id=4
- The
- So, you move the content from the site ID’s folder to your
<TARGET>
site’suploads
folder/uploads/sites/4/2016/
->/uploads/2016/
** This also means that your $table_prefix
String in wp-config.php
will include this site ID between the wp_
and the rest of the String:
- Ex:
$table_prefix = 'wp_ex54gTv';
will be'wp_4_ex54gTv'
in the SQL database for your particular subsite
1. Prepare the SQL Export
- Migrate
plugins
,themes
, anduploads
- Move them from the
<ORIGIN>
site -> the<TARGET>
site *
- Move them from the
- Replace URL and file path from the
<TARGET>
site:- Copy the URL ->
<ORIGIN>
site’s “New URL” - Copy the file path ->
<ORIGIN>
site’s “New file path” - Click “Add Row” to add subsite details
//subsite.sitename.com
->//newsite.com
- Click “Add Row” to replace your
uploads
folder Strings /uploads/sites/4/
->/uploads/
- Copy the URL ->
Now, you’re ready to Export the file.
DeliciousBrains says:
- 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.
However, that wasn’t an option for me while using the free version of the plugin. Therefore, ALL the next steps were very manual. But, I think the image from their website is helpful to know which tables to keep and which to get rid of in your SQL file:
Basically, you will want to KEEP all the WordPress data for your subsite (everything with the site ID between underscores _4_
and DELETE all the WordPress data for the main site.
Notes:
* This was one of my problems going through. I didn’t DELETE all the main site data from the SQL file, so it would import the subsite data, then overwrite it with the main site data.
2. Prepare the SQL upload
- After preparing everything as described previously, Export the SQL file
- I turned OFF Gzip so I could immediately modify the file after download
- Modify the
.sql
file in any code or text editor- Go ahead and go through and DELETE all the SQL tables that we didn’t need to select (everything that ISN’T blue in the image above).
- These will be listed in the alphabetical order shown in the image, so should be easy to find. DELETE everything from
wp_blog_versions
towp_terms
(because you’ll notice you still havewp_4_terms
and the like that contains your subsite data - Find and Replace any instances of
wp_4_
with justwp_
- Save and close the file
- Open
phpadmin
on the<TARGET>
site- Drop all
<TARGET>
site’s defaultwp_
tables - Import the NEW SQL file (you just modified)
- Drop all
- Run cleanup
- DeliciousBrains has some SQL queries you can run to remove duplicate usermeta rows as well – these didn’t work for me as the syntax in my
phpadmin
was wrong, so I manually deleted old users, etc. - Alternatively, it looks like this SQL script will do the job as well
- DeliciousBrains has some SQL queries you can run to remove duplicate usermeta rows as well – these didn’t work for me as the syntax in my
Problems?
- Whitescreen of Death? Your theme may be missing from the target site –
/wp-admin
will still work – choose a different theme, or be sure to upload the one you want - Manual DB import fails? Don’t use GZIP and export it again (larger file size)
- WP Migrate DB ate my posts? This is a migration, not merge – use WP Migrate DB Pro’s push/pull if you just want “updates”
- Media files not working? Be sure everything is uploaded (and for Multisite, be sure you changed the upload folder during your SQL export – from
/uploads/sites/4/
to/uploads/
- Migration failed? Be sure the $table_prefix Strings in your
<TARGET>
sitewp-config.php
match those in the<ORIGIN>
site’swp_config.php
Was this helpful?
I hope this write-up was helpful. Let me know in the Comments. I plan to use these notes for my next Migration as well.
Side note: WP Migrate DB Pro can do all of this FOR you automagically. It can also UPDATE your site if there is newer content on one side or the other using their push/pull
function. It would be a great option if you do lots of migrations or just want to save yourself the headache of doing it all manually.