Converting a Single WordPress Site to Multisite Using WP-CLI

Using the WP CLI command, I wanted to convert a single site to a multisite. I chose the CLI instead of the GUI because it’s much faster and the changes are direct, so I don’t have to log in and log out to deactivate all plugins and after that reactivate them. Using WP-CLI is automatically done for me.

WordPress Multisite is a powerful feature that allows you to manage multiple WordPress sites from a single installation. In this short tutorial, I’ll guide you through the process of converting a single WordPress site to Multisite using the WP-CLI (WordPress Command Line Interface). So let’s get started:

Prepare:

Check the current permalink structure by running the following command:

wp option get permalink_structure

The output might look like this:

"/%postname%/"

Note it down because we’ll use this later.

Convert to Multisite

Open your terminal and navigate to the root directory of your WordPress installation. Use the following WP-CLI command to initiate the Multisite installation:

wp core multisite-convert

Is just as simple! Only on command and you’re done. After running this command, you should see a success message like:

Success: Network installed. Don't forget to set up rewrite rules (and a .htaccess file if using Apache).

So you must update the Apache rules or Nginx rules depending on what you have. See here the .htaccess rules provided by the WP Team.

Update the permalink structure

By default, Multisite installations include a “/blog” prefix in the permalink structure. To remove this prefix, follow these steps:

Check the current permalink structure by running the following command:

wp option get permalink_structure

The output might look like this:

"/blog/%year%/%monthnum%/%day%/%postname%/"

This new permalinks structure might be totally different from the original one and for sure as you can see there’s the “/blog” prefix, which we don’t want.

Now remember that at the beginning of this article, I said to node down the permalink structure of the original single site. Use it instead to restore it again. This will ensure that there are no SEO problems with broken permalinks.

wp option update permalink_structure "/%postname%/"

Flush Rewrite Rules

Log in to the WordPress Admin and navigate to “Settings” > “Permalinks.” On the Permalinks page, simply press the “Save Changes” button to flush the rewrite rules.

Done!

Now you must have a fully function multisite install.

Member since January 2, 2019

As a seasoned WordPress developer with expertise in various tech stacks and languages, I bring years of experience to every project I handle. My passion for coding and dedication to delivering exceptional work ensures that each project I take on is of the highest quality. I specialize in creating custom themes, developing plugins, and building full-scale web systems. By staying up-to-date with the latest industry trends and best practices, I incorporate cutting-edge solutions into my work.

Comments

    Your email address will not be published. Required fields are marked *