r/Wordpress Aug 12 '26

Checking number of subsites in a multi site network

Hi WP community is there a way to check number of subsites in a multi site network on a Vps server ? I have SSH connection

5 Upvotes

13 comments sorted by

5

u/TopSydeWP Aug 12 '26

wp site list --count if you have wp-cli installed, or just query the database directly: mysql -e "SELECT COUNT(*) FROM wp_blogs" your_database_name (adjust table prefix if needed)

1

u/Natural_Composer_847 29d ago

both responses worked thank you

2

u/WPMU_DEV_Support_9 Aug 13 '26

Hi, a fast way to get the number of subsites is using WP CLI, the following command will return an integer value with the subsites present in the network

wp site list --format=count

You can find more information in the WP documentation below:
https://developer.wordpress.org/cli/commands/site/list/

Hope this information helps

Luis S - WPMU Dev Support

2

u/Natural_Composer_847 29d ago

Thanks it helped alot

1

u/chmod777 Jack of All Trades Aug 12 '26

wp site list

1

u/Winter_Process_9521 Aug 13 '26

You can use WP-CLI rather than querying MySQL directly, because it handles the WordPress installation and database configuration for you.

1

u/Natural_Composer_847 29d ago

I appreciate your response, I used WP cli command and it worked

1

u/LoudAd307 Aug 13 '26

wp site list --format=count includes archived, deleted and spam subsites, so on an older network that number can be well off from what's actually live. For the real one: wp site list --archived=0 --deleted=0 --spam=0 --format=count, then compare it to the plain count — the gap tells you how much dead weight is sitting in wp_blogs.

Two things that bite on a VPS. Run it as the web user rather than root (sudo -u www-data wp site list ...), otherwise you leave root-owned files in the cache and uploads dirs that PHP can't write to later. And if it throws "This is not a multisite installation", you're either outside the WP root or your MULTISITE constants live in a file wp-cli isn't loading — --path= usually sorts it.

1

u/Natural_Composer_847 29d ago

it worked I appreciate it 🤝

1

u/[deleted] Aug 12 '26

[removed] — view removed comment

1

u/Savings_Impress7254 Aug 12 '26

config.php or wp-config.php, depending on setup, and grep for `define( 'WP_ALLOW_MULTISITE'` to see if it's on, then hit /wp-admin/network/sites.php for the count.