WP_Site_Query::parse_query( string|array $query = '' )

Parses arguments passed to the site query with default query parameters.


Description

Top ↑

See also


Top ↑

Parameters

$query string|array Optional
Array or string of WP_Site_Query arguments. See WP_Site_Query::__construct().
More Arguments from WP_Site_Query::__construct( ... $query ) Array or query string of site query parameters.
  • site__in int[]
    Array of site IDs to include.
  • site__not_in int[]
    Array of site IDs to exclude.
  • count bool
    Whether to return a site count (true) or array of site objects.
    Default false.
  • date_query array
    Date query clauses to limit sites by. See WP_Date_Query.
    Default null.
  • fields string
    Site fields to return. Accepts 'ids' (returns an array of site IDs) or empty (returns an array of complete site objects).
  • ID int
    A site ID to only return that site.
  • number int
    Maximum number of sites to retrieve. Default 100.
  • offset int
    Number of sites to offset the query. Used to build LIMIT clause.
    Default 0.
  • no_found_rows bool
    Whether to disable the SQL_CALC_FOUND_ROWS query. Default true.
  • orderby string|array
    Site status or array of statuses. Accepts:
    • 'id'
    • 'domain'
    • 'path'
    • 'network_id'
    • 'last_updated'
    • 'registered'
    • 'domain_length'
    • 'path_length'
    • 'site__in'
    • 'network__in'
    • 'deleted'
    • 'mature'
    • 'spam'
    • 'archived'
    • 'public'
    • false, an empty array, or 'none' to disable ORDER BY clause.
    Default 'id'.
  • order string
    How to order retrieved sites. Accepts 'ASC', 'DESC'. Default 'ASC'.
  • network_id int
    Limit results to those affiliated with a given network ID. If 0, include all networks. Default 0.
  • network__in int[]
    Array of network IDs to include affiliated sites for.
  • network__not_in int[]
    Array of network IDs to exclude affiliated sites for.
  • domain string
    Limit results to those affiliated with a given domain.
  • domain__in string[]
    Array of domains to include affiliated sites for.
  • domain__not_in string[]
    Array of domains to exclude affiliated sites for.
  • path string
    Limit results to those affiliated with a given path.
  • path__in string[]
    Array of paths to include affiliated sites for.
  • path__not_in string[]
    Array of paths to exclude affiliated sites for.
  • public int
    Limit results to public sites. Accepts '1' or '0'.
  • archived int
    Limit results to archived sites. Accepts '1' or '0'.
  • mature int
    Limit results to mature sites. Accepts '1' or '0'.
  • spam int
    Limit results to spam sites. Accepts '1' or '0'.
  • deleted int
    Limit results to deleted sites. Accepts '1' or '0'.
  • lang_id int
    Limit results to a language ID.
  • lang__in string[]
    Array of language IDs to include affiliated sites for.
  • lang__not_in string[]
    Array of language IDs to exclude affiliated sites for.
  • search string
    Search term(s) to retrieve matching sites for.
  • search_columns string[]
    Array of column names to be searched. Accepts 'domain' and 'path'.
    Default empty array.
  • update_site_cache bool
    Whether to prime the cache for found sites. Default true.
  • update_site_meta_cache bool
    Whether to prime the metadata cache for found sites. Default true.
  • meta_key string|string[]
    Meta key or keys to filter by.
  • meta_value string|string[]
    Meta value or values to filter by.
  • meta_compare string
    MySQL operator used for comparing the meta value.
    See WP_Meta_Query::__construct() for accepted values and default value.
  • meta_compare_key string
    MySQL operator used for comparing the meta key.
    See WP_Meta_Query::__construct() for accepted values and default value.
  • meta_type string
    MySQL data type that the meta_value column will be CAST to for comparisons.
    See WP_Meta_Query::__construct() for accepted values and default value.
  • meta_type_key string
    MySQL data type that the meta_key column will be CAST to for comparisons.
    See WP_Meta_Query::__construct() for accepted values and default value.
  • meta_query array
    An associative array of WP_Meta_Query arguments.
    See WP_Meta_Query::__construct() for accepted values.

Default: ''


Top ↑

Source

File: wp-includes/class-wp-site-query.php. View all references

public function parse_query( $query = '' ) {
	if ( empty( $query ) ) {
		$query = $this->query_vars;
	}

	$this->query_vars = wp_parse_args( $query, $this->query_var_defaults );

	/**
	 * Fires after the site query vars have been parsed.
	 *
	 * @since 4.6.0
	 *
	 * @param WP_Site_Query $query The WP_Site_Query instance (passed by reference).
	 */
	do_action_ref_array( 'parse_site_query', array( &$this ) );
}

Top ↑

Hooks



Top ↑

Changelog

Changelog
Version Description
4.6.0 Introduced.

Top ↑

User Contributed Notes

You must log in before being able to contribute a note or feedback.