wp_get_sites()
Return an array of sites for a network or networks.
No Hooks.
Return
Array[]
. An empty array if the installation is considered "large" via wp_is_large_network(). Otherwise, an associative array of WP_Site data as arrays.
Usage
wp_get_sites( $args );
- $args(array)
Array of default arguments. Optional.
Default: array()
-
network_id(int|int[])
A network ID or array of network IDs. Set to null to retrieve sites from all networks.
Default: current network ID -
public(int)
Retrieve public or non-public sites.
Default: null, for any -
archived(int)
Retrieve archived or non-archived sites.
Default: null, for any -
mature(int)
Retrieve mature or non-mature sites.
Default: null, for any -
spam(int)
Retrieve spam or non-spam sites.
Default: null, for any -
deleted(int)
Retrieve deleted or non-deleted sites.
Default: null, for any -
limit(int)
Number of sites to limit the query to.
Default: 100 - offset(int)
Exclude the first x sites. Used in combination with the $limit parameter.
-
Examples
#1 Get all the sites in the network as an array
$array = wp_get_sites( array( 'network_id' => null, 'public' => null, 'archived' => null, 'mature' => null, 'spam' => null, 'deleted' => null, 'limit' => 100, 'offset' => 0, ) ); print_r( $array ); /* Will display Array( [0] => Array( [blog_id] => 1 [site_id] => 1 [domain] => example.com [path] => / [registered] => 2013-11-08 17:56:46 [last_updated] => 2013-11-08 18:57:19 [public] => 1 [archived] => 0 [mature] => 0 [spam] => 0 [deleted] => 0 [lang_id] => 0 ) [1] => Array( [blog_id] => 2 [site_id] => 1 [domain] => example.com [path] => /examplesubsite/ [registered] => 2013-11-08 18:07:22 [last_updated] => 2013-11-08 18:13:40 [public] => 1 [archived] => 0 [mature] => 0 [spam] => 0 [deleted] => 0 [lang_id] => 0 ) ) */
Notes
- See: get_sites()
Changelog
Since 3.7.0 | Introduced. |
Deprecated since 4.6.0 | Use get_sites() |