get_sites() WordPress Function

The get_sites() function is used to retrieve a list of sites from a WordPress network. This function is only available to networks that are running WordPress 4.6 or higher.

get_sites( string|array $args = array() ) #

Retrieves a list of sites matching requested arguments.


Description

Top ↑

See also


Top ↑

Parameters

$args

(string|array)(Optional) Array or string of arguments. See WP_Site_Query::__construct() for information on accepted arguments.

Default value: array()


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/ms-site.php

function get_sites( $args = array() ) {
	$query = new WP_Site_Query();

	return $query->query( $args );
}


Top ↑

Changelog

Changelog
VersionDescription
4.8.0Introduced the 'lang_id', 'lang__in', and 'lang__not_in' parameters.
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.