WordPress Multisite: WP-CLI Commands for Network Administration

Managing a WordPress Multisite network via the admin UI becomes tedious at scale — creating dozens of sites, bulk-activating plugins, syncing options, or migrating sub-sites all benefit from WP-CLI’s network-aware commands. The --url flag targets individual sites; the site list, site create, and --network flags operate at the network level.

Problem: Managing a WordPress Multisite network — creating sites, adding users, updating options across all sites, running database upgrades — requires navigating the Network Admin UI for each site individually, with no bulk operations.

Solution: Use WP-CLI's Multisite commands: wp site list --fields=blog_id,url,registered, wp site create --slug=client-site --title="Client", wp user add-role USER_ID --url=site-url. Run commands across all sites with wp site list --field=url | xargs -I % wp --url=% option update blogname "New Name". Use wp network meta for network-level options.


The commands below cover creating and deleting sub-sites, bulk-activating plugins network-wide, syncing a plugin's options across all sites, listing sites with custom fields, and running a WP-CLI command across every active site in a loop.


# 1. List all sites in the network (custom fields)
wp site list --fields=blog_id,url,registered,public,archived --format=table

# 2. Create a new sub-site
wp site create \
    --slug=client-a \
    --title="Client A" \
    --email=admin@client-a.com \
    --network_id=1

# 3. Activate a plugin network-wide (activates for ALL sites)
wp plugin activate my-plugin --network

# 4. Activate a plugin on a specific sub-site only
wp --url=https://network.com/client-a plugin activate my-plugin

# 5. Run a command across every active site in the network
wp site list --field=url | while read site_url; do
    echo "=== $site_url ==="
    wp --url="$site_url" cache flush
done

# 6. Sync an option value to all sites
wp site list --field=url | while read site_url; do
    wp --url="$site_url" option update my_plugin_api_key "shared-key-value"
done

# 7. Bulk-update WordPress core on all sites (runs upgrade on each)
wp core update                                  # updates files once
wp site list --field=url | while read url; do
    wp --url="$url" core update-db             # run DB upgrade per site
done

# 8. Export a sub-site and import into a standalone installation
wp --url=https://network.com/client-a export   # exports WXR
# On target standalone site:
# wp import client-a.xml --authors=create

# 9. Archive (soft-delete) a site and unarchive it
wp site archive 3       # blog_id = 3
wp site unarchive 3

# 10. Delete a site permanently (irreversible — requires confirmation)
wp site delete 3 --yes


NOTE: When running WP-CLI commands across all sites in a while read loop, add a short sleep 0.5 between iterations on production networks to avoid hammering the database with simultaneous queries from parallel shell processes if you later switch to xargs -P.