How to convert a Network Active plugin to active on each site


WordPress multisite allows plugins and themes to be Network Active. This prevents them from being deactivated on any site in the network.

To change a plugin from Network Active on every site to individually active on each site:

  1. Manually Network Deactivate the plugin from the network plugins page. The wp network command does not yet support plugin deactivation.
  2. Connect to the server via SSH and run this WP CLI command: wp site list --field=url | xargs -n1 -I % wp --url=% plugin activate hello.php (where hello.php is the plugin file or folder name)

What does the command do?

wp site list --field=url produces a list of URLs for all of the sites on the network.

The | operator passes the results from wp site list to xargs. xargs can take the output from one command and send it to another command as parameters.

The -n1 flag to xargs processes each line of output from the site list command one at a time. -n2 would send two site URLs to the next command.

wp --url=% plugin activate hello.php is the command to which xargs is passing the site URLs. It activates the Hello Dolly plugin on each site specified by URL. The % sign is our replacement character where each URL will populate.


Leave a Reply

Your email address will not be published.