Uses
Uses | Description |
---|---|
wp-includes/functions.php: get_main_site_id() | Gets the main site ID. |
wp-includes/load.php: is_multisite() | If Multisite is enabled. |
wp-includes/load.php: get_current_blog_id() | Retrieve the current site ID. |
Determine whether a site is the main site of the current network.
(int) (Optional) Site ID to test. Defaults to current site.
Default value: null
(int) (Optional) Network ID of the network to check for. Defaults to current network.
Default value: null
(bool) True if $site_id is the main site of the network, or if not running Multisite.
Replaces function is_main_blog()
, deprecated since 3.0.0. (wp-includes/ms-deprecated.php)
File: wp-includes/functions.php
function is_main_site( $site_id = null, $network_id = null ) { if ( ! is_multisite() ) { return true; } if ( ! $site_id ) { $site_id = get_current_blog_id(); } $site_id = (int) $site_id; return get_main_site_id( $network_id ) === $site_id; }
Version | Description |
---|---|
4.9.0 | The $network_id parameter was added. |
3.0.0 | Introduced. |
© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/is_main_site