WordPress Multisite Multi-Network
WordPress Multisite is a cool tool that allows you to create a network of sites. But did you know that you can create not just a network of sites (Multisite), but also a network of networks of sites (Multi-Multisite)?
Multi-network allows you to have virtually an unlimited number of Multisite networks using a single WordPress installation and database. Each network can contain virtually an unlimited number of child blogs/sites.
There are pros and cons to this:
- On one hand, you have a single installation with centralized updates for all networks and blogs/sites - all your networks are conveniently located in one place.
- On the other hand, having everything in one place makes the entire network vulnerable to hacking attacks and other security issues.
Let's figure out how multi-networks work. Their use can sometimes be beneficial for what you are currently developing.
Before You Start...
Before we move on to setting up a multi-network site, there are a few points to note.
-
First, your networks share a common physical WordPress installation and database but operate as independent Multisite networks. That is, each multisite operating under the multi-network is a full multisite. You need to access the network admin panel in each network you create and configure the network settings that are the same for each blog/site.
- Second, it’s important to understand why you need a multi-network and how you will use it. Pre-planning is key, and if you plan and expand the system before the need arises, the multi-network will help you rather than hinder you.
At some point, you will need to learn about database sharding - it’s not rocket science, but it is a more complex task that goes beyond this article. For planning and implementing DB Sharding, you will likely need to consult a DevOps specialist.
If you start delving into the Multisite database, you will realize that all blogs/sites use the same site_id=1
, located in the database table ending with _blogs
. Each blog/site will have a unique blog_id
, but they all fall under one site_id=1
. You will also notice a database table ending with _site
. This is where the multi-network writes the unique site_id
for each new Multisite network you create.
The WordPress terminology here can be a bit confusing:
- SiteID is actually the network ID - the site that is the network site of the Multisite.
- BlogID refers to any blog/site in the network. One of the blogs in the network is always the site of the network itself (the network itself).
Another feature: the multi-network allows you to move any blog/site from any of your Multisite networks to any other network operating within the same multi-network - all with minimal actions. Below, we will look into this aspect.
Getting Started with Multi-Network in WordPress
First, we need a working installation of WordPress Multisite. When creating this guide, I used cheap virtual hosting, but if you plan to create a serious multi-network, cheap hosting will not suit you - your multi-network should support a large amount of traffic and requests, so at some point, you will need to upgrade to serious hosting.
Once you have set up the Multisite network, you can configure the multi-network! Enabling it is very simple - WordPress has several great plugins that can help you with this: WP Multi Network, developed by John James Jacoby, who is the conceptual inspiration for the existence of the multi-network in the WordPress core. John explains how the multi-network works in this video:
http://wordpress.tv/2014/07/26/john-james-jacoby-multisite-and-multi-network/
So, let’s proceed to set up the multi-network:
-
Go to the Multisite network admin panel.
-
On the sidebar, select Plugins > Add New.
-
Click on the Search Plugins field in the upper right corner and enter "WP Multi Network".
-
Click Install Now and after the plugin is installed, click Network Activate.
-
Now you should see the Networks panel as the first item in the menu in the network admin panel.
-
For the multi-network to work, you need to make some changes to the
wp-config.php
file. Open the config filewp-config.php
and comment out the following line:define( 'DOMAIN_CURRENT_SITE', 'yoursite.com' );
Congratulations! Now you are operating in multi-network mode!
Log in to your network and go to the network admin panel. Now you can start adding and managing networks (or multisites) in your network.
Configuring Domain Mapping in Multi-Network
The WP Multi Network plugin manages the networks you create. This means that you can create an entire network as a subdirectory of your main network (the Multisite network you created first). Or you can choose a separate domain for each network (or Multisite) in your multi-network. The WP Multi Network plugin will take care of all this.
You will be able to map domains to any child blog/site in any of your networks using this manual Ultimate WordPress Multisite Domain Mapping Guide. If you decide to map domains to other networks or blogs/sites, each domain must be set up to point to the physical IP of your network or the public_html
directory.
This is done using the domain control panel provided by your hosting company, usually cPanel. If you are using cPanel, you will need to add your domains as aliases (or parked domains) or additional domains (depending on your hosting plan), and point each of them to the same directory of your WordPress installation. This is usually public_html
, but depending on your hosting setup, the name of the directory may vary.
If you are using DNS Made Easy or another DNS tool, you will need to add an ANAME
record for each domain you want to map to your network, pointing to the same physical IP of your WordPress Multisite. After that, and waiting for DNS changes to propagate (this can take some time), your domains will be redirected to the same directory (cPanel) or IP (DNS Made Easy).
I registered two domains that I will use for this setup. Each domain has an active SSL - we need SSL for each domain (or a multi-domain SSL covering them all):
-
https://awpmu.cloud/
- this will be the main (or leading) network. https://lwpmu.cloud/
- this will be the child (or subordinate) network.
I am going to organize my main network as follows:
-
Main multi-network - AWPMU Multisite.
-
Address of the main network -
https://awpmu.cloud/
- Main multisite - AWPMU Network - Main Site (tagline)
Next, I will create a child network (or Multisite) as follows:
-
Child multisite - LWPMU Network
-
Address of the child network -
https://lwpmu.cloud/
- Child multisite - LWPMU Network - Main Site (tagline)
I will also create a child blog under each multisite:
-
Main Multisite Child-Blog -
https://awpmu.cloud/blog01/
- Blog 01 - Child Multisite Child-Blog -
https://lwpmu.cloud/blog02/
- Blog 02
Finally, I will move these child blogs from one network (or multisite) to another, making some minor changes needed to complete the process as follows:
-
Master Multisite Child-Blog -
https://awpmu.cloud/blog02/
- Blog 02 - Slave Multisite Child-Blog -
https://lwpmu.cloud/blog01/
- Blog 01
Creating a Network
Creating a new network is very simple. Here’s how to do it:
-
Go to the admin panel of your Multisite network and click on the first menu item, which is the Networks icon created by the WP Multi Network plugin. In the upper left corner, click Add New. Fill in the required fields.
-
Enter the network name. This is the name of your new multisite.
-
Enter the domain that you mapped in cPanel or the domain control panel in the previous steps of this guide. You can use the main domain with an added path if you do not want to map another domain to the new Multisite site.
-
Enter the site name, i.e., the name for your new main site of the Network.
-
Enter the path. Use this option only if you want your new network to be in a subdirectory of the original (main) network or in a subdirectory of any other domain already mapped to the same
public_html
directory (cPanel) or other control panel. -
Click Create. You will then be redirected to the Networks page in the admin panel of your network.
Now you see that we have two networks (or multisites), each with an automatically created default site.
-
Go to PHPMyAdmin, and you will find a bunch of new tables in the database. Check the database table ending with
_site
, and you will see our new Multisite withid=2
, and in the database table ending with_blogs
, you will see the new site withblog_id=2
, andsite_id=2
. -
Before we start doing anything on our new child multisite, let’s first create a child blog on the original multisite (
site_id=1
, AWPMU Multi Network in the multi-network). Go to Sites on the sidebar in the admin panel of your main network and create a new site. You will see the main site of the multi-network there. In my case, it’sawpmu.cloud
).
Creating a Blog/Site
If you are already using WordPress Multisite, you already know that creating a new blog/site is quite simple, but let’s go through the steps anyway:
Step 1: In the admin panel of your network, go to Sites > Add New and enter the details for your new child blog/site. When you are done, click Add Site.
You will have the option to create another child blog, but for now, click Sites in the sidebar to check if your new site is there.
Looks good!
You can visit the new blog to check that it works, and go to its separate admin panel to set it up. For now, let’s check the multi-network database in PHPMyAdmin again, specifically the database table ending with _blogs
:
You will see the new child blog/site there: it uses blog_id=3
and site_id=1
since it is in the AWPMU Network/Multisite. Go to the admin panel of the child network LWPMU Multisite to create a new child blog/site. When you log into the "child" Multisite for the first time, you will be prompted to update the network, so do that before proceeding.
Repeat step 1 to create Blog 02 in the child network site_id=2
.
Then go to the Sites section in the admin panel of the LWPMU network and make sure the new child blog is there.
Next, let’s take another look at PHPMyAdmin. You will notice several new tables ending with 2, 3, and 4 (for the recently created multisite and both child blogs/sites we created - one for each network/multisite). The new child blog/site has blog_id=4
and site_id=2
in the database table ending with _blogs
. This means that it is under our child multisite, which in my case is called LWPMU Network.
Moving a Blog/Site from One Network to Another
Now let’s look at moving blogs/sites between networks within the same multi-network.
-
Go to the admin panel of the child Multisite network. In my installation, it is located at
https://lwpmu.cloud/wp-admin/network/
. -
Click on Sites, then hover over
/blog02
Child-blog/
. In the far right corner, the Move option will appear. Click on it. -
Click on the dropdown menu and select
https://awpmu.cloud/
as the new network for this blog/site. -
Then click Move to perform the move.
You will see that Blog 02 has disappeared from the Sites page. You can also check the message at the top of the dashboard confirming that the blog/site has been moved.
-
Go to the main admin panel of the Multisite network. In my installation, it is located at
https://awpmu.cloud/wp-admin/network/
. - Click on Sites. You will see that Blog 02 is now there. You will also see that it is still under
https://lwpmu.cloud/blog02
, but we want it to be under the AWPMU domain. Hover over it and click Edit.
- Change the Site Address (URL) from
lwpmu.cloud
toawpmu.cloud
, then click Save Changes.
- Click on Sites in the sidebar again and check the new address.
- Now open PHPMyAdmin again and find the database table ending with
*_blogs
. Check the newsite_id
for blog02. This confirms that blog01 and blog02 are now operating under AWPMU Multisite - both blogs have site_id=1.
- Now let’s move our Blog 01 from the AWPMU multi-network to the LWPMU network. Repeat steps 1 through 9 above. Then go to the admin panel of the child Multisite network, click on Sites, and edit Blog 01 so that it operates under LWPMU. Check PHPMyAdmin and you will see again that Blog 01 is now operating under lwpmu.cloud (site_id=2).
Conclusion
Now you can use the new WP features in multi-network mode.
Remember that each network you create in your multi-network will have its own control panel and settings - they will share a common physical installation and database but will behave as completely independent multisites.
If you have experience with multi-networks, share it in the comments.
Video
https://wordpress.tv/2014/07/26/john-james-jacoby-multisite-and-multi-network/
--