WP_Site_Query vs. WP_Network_Query in WordPress 4.6

Can someone explain the difference between WP_Site_Query and WP_Network_Query in WordPress 4.6?

  • WP_Network_Query() : Core class used for querying networks.
  • WP_Site_Query() : Core class used for querying sites.
  • WP_Term_Query() : Class used for querying terms.

Are there examples when you would query the Network vs. the Site vs. Posts?

Wouldn’t a WP_Site_Query just be a WP_Query? I’ve been hoping for a way to query posts across multiple sites but I don’t think this is that.

I wonder if Multisite Focused Changes in 4.6 would help…

1 Answer
1

When you set WordPress to multisite, in an “out of box” fashion, you create a single network of sites. Let’s, say, a network of food blogs.

With plugins like WP Multi Network you can set up multiple networks. You could split that food blogs network into several networks: mediterranean food blogs, brazilian food blogs, thai food blogs, wine blogs, etc

From what i grasp reading https://make.wordpress.org/core/2016/07/08/multisite-focused-changes-in-4-6/ and both classes sources (and their related functions/other classes), WP_Site_Query queries about existing sites in a single network (e.g. find all active sites in that network) and WP_Network_Query do the same across several networks (e.g. find all archive blogs on all those networks).

Leave a Comment