WP_Site_Query::query() WordPress Method

The WP_Site_Query::query() method is used to retrieve information about sites in a multisite network. This method can be used to get a list of all sites in the network, or to get specific information about a particular site. The WP_Site_Query::query() method accepts two arguments: The first argument is an array of query parameters. These parameters can be used to specify the site ID, domain, path, and other information about the site. The second argument is an array of options. These options can be used to specify the order in which the sites will be returned, the number of sites to be returned, and whether to include site meta information in the response.

WP_Site_Query::query( string|array $query ) #

Sets up the WordPress query for retrieving sites.


Parameters

$query

(string|array)(Required)Array or URL query string of parameters.


Top ↑

Return

(array|int) List of WP_Site objects, a list of site IDs when 'fields' is set to 'ids', or the number of sites when 'count' is passed as a query var.


Top ↑

Source

File: wp-includes/class-wp-site-query.php

	public function query( $query ) {
		$this->query_vars = wp_parse_args( $query );

		return $this->get_sites();
	}


Top ↑

Changelog

Changelog
VersionDescription
4.6.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.