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.
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.
Source
File: wp-includes/class-wp-site-query.php
public function query( $query ) { $this->query_vars = wp_parse_args( $query ); return $this->get_sites(); }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
4.6.0 | Introduced. |