函数原型
is_main_site( int $site_id = null, int $network_id = null ): bool
函数描述
Determines whether a site is the main site of the current network.
是否弃用
未弃用
函数参数
-
$site_id
int
Optional - Site ID to test. Defaults to current site.
Default:
null -
$network_id
int
Optional - Network ID of the network to check for.
Defaults to current network.Default:
null
函数返回值
bool True if $site_id is the main site of the network, or if not running Multisite.
函数位置
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. |

