How can I (easily) determine which of my wordpress sites are using a given plugin, on a Wordpress Multisite install?

Let's say I have 1,000 wordpress sites on a Wordpress Multisite install. I have 100 plugins.

For each plugin, I want to list all of the sites that are using that plugin.

In the GUI, I can only see how this can be done in about 1 million clicks. Is there a query I can run against the DB (and maybe cleanup with bash/awk/etc) that will automatically

  1. Get all of the plugins installed
  2. For each plugin, list all of the sites that use that plugin (by site-id is fine)

What's a fast way to determine all of the sites that use each of my installed plugins on Wordpress Multisite?

  • 2
    are you comfortable using WP CLI? If so there may be CLI based solutions here that don't require additional PHP/SQL
    – Tom J Nowell
    Commented May 17, 2022 at 17:13
  • wp-cli is definitely a valid answer to this question. However, for this server, I can only use software that can be installed from a secure package manager with cryptographically signed manifests (which apt provides but composer, curl, git, brew, etc do not provide) Commented May 18, 2022 at 7:30
  • So uploading or downloading wp-cli.phar as the wp cli homepage says in that environment is not an option? Even then nothing prevents you downloading the data and running WP CLI locally, and WP CLI may be a hard requirement as you mentioned 1k+ sites ( and ignoring that files and commits in git are all managed using a cryptographic hash chain )
    – Tom J Nowell
    Commented May 18, 2022 at 13:23

3 Answers 3


You can list the sites a plugin has been activated on in the shell using WP CLI:

sites=$(wp site list --field=url)
for url in $sites; do
    if wp plugin is-active "YOURPLUGINNAME" --url="${url}" --network; then
        echo "${url}"

It will print out the URL of each site on its own line that has that plugin activated.

  • Unfortunately, this does not print the site if a plugin is enabled network-wide. Commented May 21, 2022 at 10:35
  • 1
    @MichaelAltfield that was never mentioned in the original post, my answer tries to list the active plugins on a site as your question requested, and if a plugin is network activated then it is not activated on those sites (but gets loaded anyway). Remember, I'm not trying to give you the answer you want, I'm trying to answer the question you asked. If there are things you expect that aren't said in your question, you have to say them. Listing plugins activated network wide requires a separate and fundamentally different answer ( aka just list all sites )
    – Tom J Nowell
    Commented May 23, 2022 at 11:41
  • I've updated my answer by adding --network as instructed by the official WP CLI docs for the plugin is-active command: developer.wordpress.org/cli/commands/plugin/is-active, but I would note this was not a part of the original question
    – Tom J Nowell
    Commented May 23, 2022 at 11:48

I just stumbled upon an extension to WP-CLI that organizes the urls for each plugin queried, on Github.

So I modified the solution by @michael-altfield to get better results:

plugins=$(wp --quiet plugin list --field=name 2> /dev/null)
# List all plugins first
printf "${plugins}\n\n"
for plugin in $plugins; do
   wp plugin active-on-sites "${plugin}"
  • Looks good, although this prints network activated plugins at the top of the list whereas it looks like the OP wanted each individual site listed for network-activated plugins (not sure why :-/ )
    – Rup
    Commented Mar 4 at 11:00
  • Well, the script will give a warning like, Warning: woocommerce is network-activated. in the terminal, so that it doesn't have to list all 1000 sites (chuckles).. Commented Mar 4 at 11:48

The following code uses wp-cli and will iterate through all plugins and it will print all sites that use each of those plugins.

sites=$(wp --quiet site list --field=url 2> /dev/null)
plugins=$(wp --quiet plugin list --field=name 2> /dev/null)
for plugin in $plugins; do
   echo $plugin;

   for url in $sites; do
      wp --quiet plugin is-active "${plugin}" --url="${url}" --network 2> /dev/null
      if [[ $? -eq 0 ]]; then

         echo -e "\t${url}"


Credit to @tom-j-nowell as the above code is a modified version of his answer, but this also loops through plugins.

  • Why would you redirect all error output 2> /dev/null? You should check of there are actually valid errors and display them in case. Commented Mar 21, 2023 at 22:02
  • Because there are invalid errors :) My server has some hardening that makes wp-cli spew out a ton of "errors" to stderr that make the output unreadable. Honestly, nobody should enable ini_set(); it defeats the purpose of hardening PHP at all :D Commented Mar 21, 2023 at 22:04
  • Well, this make this a very specific answer for yourself. Not something I would recommend people to copy and use like this. So wp-cli does not need ini_set but produces errors if its disabled? Commented Mar 21, 2023 at 23:07
  • It prints a ton of (non-critical) errors on any basic hardening. So this cleans it up for anyone (not just me) who follows basic PHP security best-practices Commented Mar 22, 2023 at 0:05
  • This will actually only print plugins which are NETWORK active (That's what the --network flag does). If you remove that flag, this code does indeed loop through each site and each plugin and check to see if that plugin is active on the given site. With the --network flag, it will only report on plugins that are active network-wide.
    – Kevin
    Commented Jul 6, 2023 at 19:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.