get_main_site_id( int $network_id = null ): int

In this article

Gets the main site ID.

Parameters

$network_idintoptional
The ID of the network for which to get the main site.
Defaults to the current network.

Default:null

Return

int The ID of the main site.

Source

function get_main_site_id( $network_id = null ) {
	if ( ! is_multisite() ) {
		return get_current_blog_id();
	}

	$network = get_network( $network_id );
	if ( ! $network ) {
		return 0;
	}

	return $network->site_id;
}

Changelog

VersionDescription
4.9.0Introduced.

User Contributed Notes

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