get_current_network_id(): int

Retrieves the current network ID.


Return

int The ID of the current network.


Top ↑

Source

File: wp-includes/load.php. View all references

function get_current_network_id() {
	if ( ! is_multisite() ) {
		return 1;
	}

	$current_network = get_network();

	if ( ! isset( $current_network->id ) ) {
		return get_main_network_id();
	}

	return absint( $current_network->id );
}


Top ↑

Changelog

Changelog
Version Description
4.6.0 Introduced.

Top ↑

User Contributed Notes

  1. Skip to note 1 content
    Contributed by Preliot

    Warning: This function returns the site_id and not the expected blog_id in multisite context.

    I was creating a plugin and used get_current_network_id() to get the current network site. It seemed to fail, because it kept returning 1. The solution was to use get_current_blog_id().

You must log in before being able to contribute a note or feedback.