WP_Site_Query::__construct( string|array $query = '' )
Sets up the site query, based on the query vars passed.
Parameters
- $query
-
(Optional) Array or query string of site query parameters. <br>
- 'site__in'
(int[]) Array of site IDs to include. <br> - 'site__not_in'
(int[]) Array of site IDs to exclude. <br> - 'count'
(bool) Whether to return a site count (true) or array of site objects.<br> Default false.<br> - 'date_query'
(array) Date query clauses to limit sites by. See WP_Date_Query.<br> Default null.<br> - 'fields'
(string) Site fields to return. Accepts 'ids' (returns an array of site IDs) or empty (returns an array of complete site objects). <br> - 'ID'
(int) A site ID to only return that site. <br> - 'number'
(int) Maximum number of sites to retrieve. Default 100.<br> - 'offset'
(int) Number of sites to offset the query. Used to build LIMIT clause.<br> Default 0.<br> - 'no_found_rows'
(bool) Whether to disable theSQL_CALC_FOUND_ROWS
query. Default true.<br> - 'orderby'
(string|array) Site status or array of statuses. Accepts:<br>- 'id'<br>
- 'domain'<br>
- 'path'<br>
- 'network_id'<br>
- 'last_updated'<br>
- 'registered'<br>
- 'domain_length'<br>
- 'path_length'<br>
- 'site__in'<br>
- 'network__in'<br>
- 'deleted'<br>
- 'mature'<br>
- 'spam'<br>
- 'archived'<br>
- 'public'<br>
- false, an empty array, or 'none' to disable
ORDER BY
clause.<br> Default 'id'.<br>
- 'order'
(string) How to order retrieved sites. Accepts 'ASC', 'DESC'. Default 'ASC'.<br> - 'network_id'
(int) Limit results to those affiliated with a given network ID. If 0, include all networks. Default 0.<br> - 'network__in'
(int[]) Array of network IDs to include affiliated sites for. <br> - 'network__not_in'
(int[]) Array of network IDs to exclude affiliated sites for. <br> - 'domain'
(string) Limit results to those affiliated with a given domain. <br> - 'domain__in'
(string[]) Array of domains to include affiliated sites for. <br> - 'domain__not_in'
(string[]) Array of domains to exclude affiliated sites for. <br> - 'path'
(string) Limit results to those affiliated with a given path. <br> - 'path__in'
(string[]) Array of paths to include affiliated sites for. <br> - 'path__not_in'
(string[]) Array of paths to exclude affiliated sites for. <br> - 'public'
(int) Limit results to public sites. Accepts '1' or '0'. <br> - 'archived'
(int) Limit results to archived sites. Accepts '1' or '0'. <br> - 'mature'
(int) Limit results to mature sites. Accepts '1' or '0'. <br> - 'spam'
(int) Limit results to spam sites. Accepts '1' or '0'. <br> - 'deleted'
(int) Limit results to deleted sites. Accepts '1' or '0'. <br> - 'lang_id'
(int) Limit results to a language ID. <br> - 'lang__in'
(string[]) Array of language IDs to include affiliated sites for. <br> - 'lang__not_in'
(string[]) Array of language IDs to exclude affiliated sites for. <br> - 'search'
(string) Search term(s) to retrieve matching sites for. <br> - 'search_columns'
(string[]) Array of column names to be searched. Accepts 'domain' and 'path'.<br> Default empty array.<br> - 'update_site_cache'
(bool) Whether to prime the cache for found sites. Default true.<br> - 'update_site_meta_cache'
(bool) Whether to prime the metadata cache for found sites. Default true.<br> - 'meta_key'
(string|string[]) Meta key or keys to filter by.<br> - 'meta_value'
(string|string[]) Meta value or values to filter by.<br> - 'meta_compare'
(string) MySQL operator used for comparing the meta value.<br> See WP_Meta_Query::__construct() for accepted values and default value.<br> - 'meta_compare_key'
(string) MySQL operator used for comparing the meta key.<br> See WP_Meta_Query::__construct() for accepted values and default value.<br> - 'meta_type'
(string) MySQL data type that the meta_value column will be CAST to for comparisons.<br> See WP_Meta_Query::__construct() for accepted values and default value.<br> - 'meta_type_key'
(string) MySQL data type that the meta_key column will be CAST to for comparisons.<br> See WP_Meta_Query::__construct() for accepted values and default value.<br> - 'meta_query'
(array) An associative array of WP_Meta_Query arguments.<br> See WP_Meta_Query::__construct() for accepted values.<br>
Default value: ''
- 'site__in'
Source
File: wp-includes/class-wp-site-query.php
public function __construct( $query = '' ) {
$this->query_var_defaults = array(
'fields' => '',
'ID' => '',
'site__in' => '',
'site__not_in' => '',
'number' => 100,
'offset' => '',
'no_found_rows' => true,
'orderby' => 'id',
'order' => 'ASC',
'network_id' => 0,
'network__in' => '',
'network__not_in' => '',
'domain' => '',
'domain__in' => '',
'domain__not_in' => '',
'path' => '',
'path__in' => '',
'path__not_in' => '',
'public' => null,
'archived' => null,
'mature' => null,
'spam' => null,
'deleted' => null,
'lang_id' => null,
'lang__in' => '',
'lang__not_in' => '',
'search' => '',
'search_columns' => array(),
'count' => false,
'date_query' => null, // See WP_Date_Query
'update_site_cache' => true,
);
if ( ! empty( $query ) ) {
$this->query( $query );
}
}
Changelog
Version | Description |
---|---|
5.3.0 | Introduced the 'meta_type_key' parameter. |
5.1.0 | Introduced the 'update_site_meta_cache', 'meta_query', 'meta_key', 'meta_compare_key', 'meta_value', 'meta_type', and 'meta_compare' parameters. |
4.8.0 | Introduced the 'lang_id', 'lang__in', and 'lang__not_in' parameters. |
4.6.0 | Introduced. |