is_main_network

Determine whether a network is the main network of the Multisite install.

Description

is_main_network( (null) $network_id = null ); 

Parameters (1)

0. $network_id — Optional. (null) => null
Network ID to test. Defaults to current network.

Usage

  1. if ( !function_exists( 'is_main_network' ) ) { 
  2. require_once ABSPATH . WPINC . '/functions.php'; 
  3.  
  4. // Optional. Network ID to test. Defaults to current network. 
  5. $network_id = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = is_main_network($network_id); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/functions.php  
  1. function is_main_network( $network_id = null ) { 
  2. if ( ! is_multisite() ) { 
  3. return true; 
  4.  
  5. if ( null === $network_id ) { 
  6. $network_id = get_current_network_id(); 
  7.  
  8. $network_id = (int) $network_id; 
  9.  
  10. return ( $network_id === get_main_network_id() );