get_current_network_id

Retrieves the current network ID.

Description

(int) get_current_network_id(); 

Returns (int)

The ID of the current network.


Usage

  1. if ( !function_exists( 'get_current_network_id' ) ) { 
  2. require_once ABSPATH . WPINC . '/load.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = get_current_network_id(); 
  7.  

Defined (1)

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

/wp-includes/load.php  
  1. function get_current_network_id() { 
  2. if ( ! is_multisite() ) { 
  3. return 1; 
  4.  
  5. $current_network = get_network(); 
  6.  
  7. if ( ! isset( $current_network->id ) ) { 
  8. return get_main_network_id(); 
  9.  
  10. return absint( $current_network->id );