The get_networks() WordPress PHP function retrieves a list of networks based on the provided arguments.
Usage
$networks = get_networks( $args );
Custom example:
$args = array( 'number' => 3, 'order' => 'DESC' ); $networks = get_networks( $args );
Parameters
$args
(string|array) Optional: Array or string of arguments. See WP_Network_Query::parse_query() for information on accepted arguments.
More information
See WordPress Developer Resources: get_networks()
Examples
Get all networks
This example retrieves all networks.
$networks = get_networks();
Get networks with specific IDs
This example retrieves networks with the IDs 1, 3, and 5.
$args = array( 'network__in' => array( 1, 3, 5 ) ); $networks = get_networks( $args );
Get networks excluding specific IDs
This example retrieves networks excluding the IDs 2 and 4.
$args = array( 'network__not_in' => array( 2, 4 ) ); $networks = get_networks( $args );
Get networks affiliated with a specific domain
This example retrieves networks affiliated with the domain “example.com”.
$args = array( 'domain' => 'example.com' ); $networks = get_networks( $args );
Search networks by a search term
This example retrieves networks matching the search term “my-network”.
$args = array( 'search' => 'my-network' ); $networks = get_networks( $args );