WP_Site_Query Generator

Overview

Use this tool to create custom code for WordPress Site Query with WP_Site_Query class.

Usage

  • Fill in the user-friendly form.
  • Click the “Update Code” button.
  • Copy the code to your project.
  • Or save it as a snippet and share with the community.

Examples

If you are still learning how to use this tool, check out the following examples:

The variable used in the code.
Show the site loop.
Return single site by ID.
Use comma separated list of sites IDs to include.
Use comma separated list of sites IDs to exclude.
Return sites from a given network. To include all networks use 0. Default 0.
Use comma separated list of network IDs to include.
Use comma separated list of network IDs to exclude.
Return sites from a given domain.
Use comma separated list of domains to include.
Use comma separated list of domains to exclude.
Return sites from a given path.
Use comma separated list of paths to include.
Use comma separated list of paths to exclude.
Return public sites only.
Return archived sites only.
Return mature sites only.
Return spam sites only.
Return deleted sites only.
Number of sites to return.
Number of sites to displace or pass over.
Ascending or Descending order.
Sort retrieved sites by.
Whether to return a site count (true) or array of site objects (false).
Site fields to return.
Whether to prime the cache for found sites
Whether to disable the "SQL_CALC_FOUND_ROWS" query.
  Save Snippet
// WP_Site_Query arguments
$args = array(
	'network__in'       => array( '5', '38', '45' ),
	'network__not_in'   => array( '10', '18', '32', '44', '56', '57', '58' ),
);

// The Site Query
$site_query = new WP_Site_Query( $args );