On this page
get_networks( string|array $args = array() ): array|int
Retrieves a list of networks.
Parameters
$argsstring|array Optional-
Array or string of arguments. See WP_Network_Query::parse_query() for information on accepted arguments.
More Arguments from WP_Network_Query::parse_query( ... $query )
Array or query string of network query parameters.
network__inint[]Array of network IDs to include.network__not_inint[]Array of network IDs to exclude.countboolWhether to return a network count (true) or array of network objects.
Default false.fieldsstringNetwork fields to return. Accepts'ids'(returns an array of network IDs) or empty (returns an array of complete network objects).numberintMaximum number of networks to retrieve. Default empty (no limit).offsetintNumber of networks to offset the query. Used to build LIMIT clause.
Default 0.no_found_rowsboolWhether to disable theSQL_CALC_FOUND_ROWSquery. Default true.orderbystring|arrayNetwork status or array of statuses. Accepts'id','domain','path','domain_length','path_length'and'network__in'. Also accepts false, an empty array, or'none'to disableORDER BYclause. Default'id'.orderstringHow to order retrieved networks. Accepts'ASC','DESC'. Default'ASC'.domainstringLimit results to those affiliated with a given domain.domain__instring[]Array of domains to include affiliated networks for.domain__not_instring[]Array of domains to exclude affiliated networks for.pathstringLimit results to those affiliated with a given path.path__instring[]Array of paths to include affiliated networks for.path__not_instring[]Array of paths to exclude affiliated networks for.searchstringSearch term(s) to retrieve matching networks for.update_network_cacheboolWhether to prime the cache for found networks. Default true.
Default:
array()
Return
array|int List of WP_Network objects, a list of network IDs when 'fields' is set to 'ids', or the number of networks when 'count' is passed as a query var.
Source
File: wp-includes/ms-network.php. View all references
function get_networks( $args = array() ) {
$query = new WP_Network_Query();
return $query->query( $args );
}
Related
Uses
| Uses | Description |
|---|---|
| WP_Network_Query::__construct() wp-includes/class-wp-network-query.php | Constructor. |
Used By
| Used By | Description |
|---|---|
| ms_load_current_site_and_network() wp-includes/ms-load.php | Identifies the network and site of a requested domain and path and populates the corresponding network and site global objects as part of the multisite bootstrap process. |
| WP_Network::get_by_path() wp-includes/class-wp-network.php | Retrieves the closest matching network for a domain and path. |
| get_main_network_id() wp-includes/functions.php | Gets the main network ID. |
| get_admin_users_for_domain() wp-includes/ms-deprecated.php | Get the admin for a domain/path combination. |
Changelog
| Version | Description |
|---|---|
| 4.6.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_networks