W
WordPress SOPKnowledge Base
Search
← All topics

WordPress Multisite Network

runnable

WordPress Multisite setup: enabling network, subdomain vs subdirectory modes, wp-config constants, WP-CLI site management commands, network plugin activation, and custom domain mapping.

multisitenetworkwp-clidomain-mappingdatabase
Agent trigger phrases: wordpress multisite · wp multisite setup · wordpress network · subdomain multisite · domain mapping wordpress · network activate plugin · multisite database tables

WordPress Multisite manages many sites from a single installation. Use when running multiple branded sites on the same server.

Enable Multisite

// Step 1: Add to wp-config.php before "That's all, stop editing"
define('WP_ALLOW_MULTISITE', true);

Then: Admin > Tools > Network Setup > Network of Sites > Install.

After install wizard, add to wp-config.php:

define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);     // false = subdirectory, true = subdomain
define('DOMAIN_CURRENT_SITE', 'example.com');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);

Subdomain vs Subdirectory

| Mode | URL Pattern | DNS Required | |------|-------------|--------------| | Subdirectory | example.com/site2/ | No extra DNS | | Subdomain | site2.example.com | Wildcard A record (*.example.com) |

WP-CLI Multisite Operations

# List all sites in network
wp site list

# Create a new site
wp site create --slug=newsite --title="New Site" --email=admin@example.com

# Delete a site
wp site delete 5

# Network-activate a plugin across all sites
wp plugin activate woocommerce --network

# List network-activated plugins
wp plugin list --network

# Run command on specific site
wp --url=example.com/site2 plugin list

Database Structure

Each site gets prefixed tables (site_id = 2):

  • wp_2_posts, wp_2_postmeta, wp_2_options, wp_2_terms

Shared across all sites:

  • wp_users, wp_usermeta, wp_blogs, wp_sitemeta

Custom Domain Mapping

  1. Install "WP Multisite Domain Mapping" or MU plugin
  2. Add custom domain as A record pointing to server IP
  3. Network Admin > Sites > Edit Site > Domain: enter custom domain (e.g., customdomain.com)
  4. Ensure SSL covers the custom domain (Let's Encrypt wildcard or per-domain)

Multisite Plugin Handling

  • Network-activated: applies to all sites, managed from Network Admin
  • Site-activated: only applies to that site
  • Must-use (mu-plugins/): auto-loaded, cannot be deactivated by site admins