WordPress at a glance

get_main_site_id() WP 1.0

Gets the main site ID.

Works based on: get_network()

No Hooks.

Return

Int. The ID of the main site.

Usage

get_main_site_id( $network_id );
$network_id(int)
The ID of the network for which to get the main site.
Default: current network

Code of get_main_site_id: wp-includes/functions.php VER 4.9.8

<?php
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;
}

Related Functions

From category: Multisite

No comments
    Hello, !     Log In . Register