wppaste
WordPress

WP_Site_Query

Since
4.6.0
Source
wp-includes/class-wp-site-query.php:17
Core class used for querying sites.

Compatibility

WordPress
since 4.6.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Hooks and filters fired · 7

Every hook that fires from inside WP_Site_Query, in the order it appears in the class, grouped by the method that fires it.

Properties · 10

$requeststringpublic
SQL for database query.
$sql_clausesarrayprotected
SQL query clauses.
$meta_queryWP_Meta_Querypublic
Metadata query container.
$meta_query_clausesarrayprotected
Metadata query clauses.
$date_queryWP_Date_Querypublic
Date query container.
$query_varsarraypublic
Query vars set by the user.
$query_var_defaultsarraypublic
Default values for query vars.
$sitesarraypublic
List of sites located by the query.
$found_sitesintpublic
The amount of found sites for the current query.
$max_num_pagesintpublic
The number of pages.

Methods · 9

  • __construct()Sets up the site query, based on the query vars passed.
  • parse_query()Parses arguments passed to the site query with default query parameters.
  • query()Sets up the WordPress query for retrieving sites.
  • get_sites()Retrieves a list of sites matching the query vars.
  • get_site_ids()Used internally to get a list of site IDs matching the query vars.
  • set_found_sites()Populates found_sites and max_num_pages properties for the current query if the limit clause was used.
  • get_search_sql()Used internally to generate an SQL string for searching across multiple columns.
  • parse_orderby()Parses and sanitizes 'orderby' keys passed to the site query.
  • parse_order()Parses an 'order' query variable and cast it to 'ASC' or 'DESC' as necessary.

Source code

#[AllowDynamicProperties]class WP_Site_Query { 	/**	 * SQL for database query.	 *	 * @since 4.6.0	 * @var string	 */	public $request; 	/**	 * SQL query clauses.	 *	 * @since 4.6.0	 * @var array	 */	protected $sql_clauses = array(		'select'  => '',		'from'    => '',		'where'   => array(),		'groupby' => '',		'orderby' => '',		'limits'  => '',	); 	/**	 * Metadata query container.	 *	 * @since 5.1.0	 * @var WP_Meta_Query	 */	public $meta_query = false; 	/**	 * Metadata query clauses.	 *	 * @since 5.1.0	 * @var array	 */	protected $meta_query_clauses; 	/**	 * Date query container.	 *	 * @since 4.6.0	 * @var WP_Date_Query A date query instance.	 */	public $date_query = false; 	/**	 * Query vars set by the user.	 *	 * @since 4.6.0	 * @var array	 */	public $query_vars; 	/**	 * Default values for query vars.	 *	 * @since 4.6.0	 * @var array	 */	public $query_var_defaults; 	/**	 * List of sites located by the query.	 *	 * @since 4.6.0	 * @var array	 */	public $sites; 	/**	 * The amount of found sites for the current query.	 *	 * @since 4.6.0	 * @var int	 */

Changelog

Introduced in 4.6.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.0.4 tag, from src/wp-includes/class-wp-site-query.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.