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
Changelog
Since 4.9.0 | Introduced. |
Code of get_main_site_id() get main site id WP 5.6.2
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;
}