How to Export a Sub Site from a WordPress Multisite

Recently, I started messing with a WordPress Multisite and figured it was about time to finally see what it was all about. I’ve always understood the basics of a Multisite, but never had a reason to venture into one, until now. My demos for my WordPress themes and plugins are now a multisite, which makes it easier for me to maintain.

If you don’t know what it is — it’s basically a single WordPress install that can provide many, many, many individual sub-sites, or child sites, using a single WordPress installation. In other words, just like how wordpress.com works. There are pros and cons to using a WordPress network which I am not going to go into details here, but rather how to export a sub site into it’s own standalone install.

There are two ways to go about it. First you can use the export/import tool under Tools to grab your content, pages, post, custom post types, etc and then import that xml file into your new install. Most of the time this will be fine, but it does not bring over your widgets, theme options, plugin options, or site settings. Your other option is to use a database dump and do a few find/replace commands. This in my opinion is the better option as you’ll have all the database information and settings. For either scenario, you’ll still need to FTP and download your theme, plugins and media library.

Let’s discuss using the second option. In our workflow below, we will be using #4 for our child site ID. This number will be different depending on which site you are exporting from your setup.

Before we begin, always make a backup!!!! And if you’re able, practice first on a local setup instead of live.

1. When you’re planning to export a subsite, you first need to see what you need.  Using an FTP application, you’ll need to download the active theme (and child if using one) and the active plugins. Keep in mind, that you may have network enabled plugins which would not show on the sub site’s plugin admin page. So you’ll want to grab these too.

2. With multisite networks, each child site’s media library is placed into an ID number subfolder. So for example, if you’re going to export a child site with ID #4 (each subsite has a unique ID), using FTP, you’ll download the folder /wp-contents/uploads/sites/4/.

3. Now you’ll want to get a database dump. The best option is to use phpmyadmin and only dump the tables you need as there is only one database for all the sites in the network. When downloading the database, only download the tables with the site ID needed. So for our example, if we’re downloading site #4, the table we will need will start with wp_4_{table_name}. In addition to these, also include in your download the wp_usermeta, wp_users tables. Note that the “wp_” prefix may be different based on how you  initially installed WordPress.

4. Now with a text editor, you’ll need to find and replace “wp_4_” with “wp_” within the database sql file you just downloaded. This will now match the wp_users and wp_usermeta tables that are already there.

5. Download a new copy and the same version of WP that you were using on the multisite to a folder on your computer. Copy over the theme and plugins into their usual places within /wp-content/. Next, take the media library that you downloaded and MOVE the contents of the /sites/4/ folder to /uploads/ in your new install.

6. Upload your new install to your server and import your edited database. In wp.config.php, change your credentials for the new database name, user and password and make any additional changes needed in this file for your setup.

7. Using a tool such as the Database Search and Replace script. You’ll need to find and replace a few entries. This script is great because it also accounts for serialized data. If you are changing domain URL’s, go ahead and do this here. Most likely you’ll need to as with a multisite the child site is either a subdomain or sub directory of the root, unless you were using domain mapping.

But most importantly, we need to change the URL’s of your media files. In the original child site, they would look something like the following: domain.com/wp-content/uploads/sites/4/2015/03/image.jpg. What we need to do is replace “/wp-content/uploads/sites/4” with “/wp-content/uploads”. Make sure you match if you are also including the last forward slash or not in your find and replace.

8. Login to the new install, re-save your permalinks and check your theme and plugin settings. They should all be there. Also, you’ll need to head over to users and remove any that should not be on this site.

If all goes well, you should have the child site now as a main site in it’s own install.

Back To Top