函数原型
get_main_site_id( int $network_id = null ): int
函数描述
Gets the main site ID.
是否弃用
未弃用
函数参数
-
$network_id
int
Optional - The ID of the network for which to get the main site.
Defaults to the current network.Default:
null
函数返回值
int The ID of the main site.
函数位置
File: wp-includes/functions.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;
}
源码链接
变更日志
| Version | Description |
|---|---|
| 4.9.0 | Introduced. |

