General Site Network Domain Path Search Type Pagination Order Count Return Fields Cache 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: Search specific sites Return network sites Return sites by domains Return only public sites Return deleted sites IDs Query Variable Name The variable used in the code. Show The Loop Yes No Show the site loop. Site ID Return single site by ID. Sites IDs In Use comma separated list of sites IDs to include. Sites IDs Not In Use comma separated list of sites IDs to exclude. Network ID Return sites from a given network. To include all networks use 0. Default 0. Network IDs In Use comma separated list of network IDs to include. Network IDs Not In Use comma separated list of network IDs to exclude. Domain Return sites from a given domain. Domains In Use comma separated list of domains to include. Domains Not In Use comma separated list of domains to exclude. Path Return sites from a given path. Paths In Use comma separated list of paths to include. Paths Not In Use comma separated list of paths to exclude. Search Return sites matching the search criteria. Search Columns Comma separated list of column names to be searched. Accepts 'domain' and 'path'. Default empty. Public Choose... True False - Default Return public sites only. Archived Choose... True False - Default Return archived sites only. Mature Choose... True False - Default Return mature sites only. Spam Choose... True False - Default Return spam sites only. Deleted Choose... True False - Default Return deleted sites only. Number Number of sites to return. Offset Number of sites to displace or pass over. Order Choose... ASC - Default DESC Ascending or Descending order. Order by Choose... Site ID (default) Site IDs In Network ID Network IDs In Domain Domain Length Path Path Length Registeration Date Last Updated None Sort retrieved sites by. Counts Choose... True False - Default Whether to return a site count (true) or array of site objects (false). Return Fields All fields (Default) Site IDs Site fields to return. Sites Cache Choose... True False - Default Whether to prime the cache for found sites No Found Rows Choose... True - Default False Whether to disable the "SQL_CALC_FOUND_ROWS" query. Update Code Save Snippet
// WP_Site_Query arguments $args = array( ); // The Site Query $site_query = new WP_Site_Query( $args );