get_main_site_id()
Gets the main site ID.
Uses: 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
Examples
#1 Get the ID of the main network site.
$main_site_id = get_main_site_id();
Changelog
Since 4.9.0 | Introduced. |
get_main_site_id() get main site id code WP 6.7.1
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; }