WordPress Multisite is the default feature of WordPress that lets you create a collection of independent websites sharing the same WordPress installation. These websites don’t have their directory on the server and act as virtual websites. However, all these websites have separate directories for the media uploads and individual tables in the database. WordPress by default provides you the functionality to create the Multisite from the admin dashboard.
You can easily create the new WordPress Multisite from the WordPress admin panel. You need to set up a few things only and your multisite WordPress website will be ready to use. Check out the screenshot of creating a multisite from the WordPress Admin.
The user thinks that it takes hours to set up the multisite network for the WordPress website. But the fact is that it takes only a few minutes to set up the network. Admin can easily create that from the backend. But what if you don’t wish to involve the admin whenever you wish to create the version of the multisite?
Yes, it is possible and very easy to set up. What you need to do is just a little bit of custom coding and you will be all set to setup your dynamic multisite WordPress setup. People think that it’s time to take the task of creating a new site. Here, I am giving you the formula to set up the multisite WordPress website in less than 60 minutes.
There is a function in WordPress that will create a new blog in multisite: wpmu_create_blog
This function has 4 parameters.
The function will return the site id on success and WP_error object on failure.
$site_id = wpmu_create_blog ( 'krishaweb.com', '/newsite', ‘Title of New site’, ‘1’ );
Now, if you wish to activate any theme for the newly created site, you first need to switch to the site using the switch_to_blog
function. This function will allow you to get the details of any blog. You just need to pass the site id to it as the parameter.
switch_to_blog( $site_id );
Now you can use the switch_theme
function that will allow the provided theme to activate for the current site.
switch_theme( ‘theme_name’ );
And that’s it. The website is ready with the theme you have activated for it. You can make amendments to it from the admin panel.
Just the one last step to restore the current blog as we have used switch_to_blog function. For that the function is restore_current_blog
.
restore_current_blog();
So, this is how you can set up a dynamic WordPress Multisite using the code in less than 60 minutes. I assure you, that this guide will help you create a WordPress multisite network easily for your international business. Feel free to reach out to us if you have any queries related to WordPress. We would love to help you with your WordPress needs.
Subscribe to our newsletter and learn about the latest digital trends.