So you have one or more single WordPress installs that you would like to merge into one WordPress network install? This article will give you some pointers on what needs to be done, and in what order.
The sites do not have to have similar domains, since WordPress can map completely different domain names internally.
For this you will need to be familiar with:
- your webhost’s control panel
- setting up a WordPress network
- DNS settings
Step: Back up your existing files and database
For each site you are merging, you will need to to back up the files and the install’s database.
This can be done either with the webhost’s control panel tools – file manager and phpMyadmin (or similar) – or using various backup plugins.
If you’re using the control panel tools, copy the following directories:
Hopefully all your plugins are well-behaved and store their data in the upload directory.
If you plan on also copying over the users of the sites, note that WordPress networks share the same user list. Importing users via backup plugins is generally easier, since otherwise you have to manually track which posts and comments are written by which user ID, and then map the user ID to the appropriate new user ID in the network.
Step: Prepare the webhost
On the webhost that will host the network, create the appropriate domain entries.
Create the database that will store the whole network install.
Since the sites already exist but elsewhere, you will not be able to reach both locations (existing sites and the network) at the same time. To do this, edit your hosts file to point the existing sites to the new webhost.
Visiting the “existing” site with the new IP address in the hosts file should land you at the install screen for a new WordPress install (the new network). Install WordPress normally and then create the network.
Step: Create sites
For each site you are merging, create a site in the network. Keep track of which site has which site ID in the network.
Step: Import content
Copy over the themes and plugins to the wp-content directory. All sites will have access to the same plugins and themes.
For each site, find the ID of the site in the wp-content/uploads/sites/ directory. Copy the files to the directory that has the site ID.
In the database, replace the content of tables with the site ID prefix (usually wp_123_) with those tables you backed up. So your wp_posts becomes wp_123_posts, etc.
If you are using a plugin, importing a backed-up site should be much easier and painless.
If you’re not interested in merging any users, now is the time to test the new network to see if all posts, plugins and themes have been correctly copied.
Step: Switch DNS
When you’re satisfied that everything works well with your hosts file modification, clear the hosts file of your changes and then update the DNS setting(s) in your webhost (or domain registrar) so that the sites are pointed to the new webhost.
If you only have 1 admin user per site, and all posts on all of the sites in the new network should belong to the user, then you don’t have to do anything special.
If you have several users and want to keep the associations between the user – post – comments, then importing will be a bit trickier.
As mentioned above, if you’re using a plugin to backup and restore the sites this should be easier. If manually importing, it would be easiest to write a script that keeps track of the old and equivalent new user IDs for each site. For example, Edward might be user #3 on Site A, but he could be user #12 on Site B.