函数原型
is_main_network( int $network_id = null ): bool
函数描述
Determines whether a network is the main network of the Multisite installation.
是否弃用
未弃用
函数参数
-
$network_id
int
Optional - Network ID to test. Defaults to current network.
Default:
null
函数返回值
bool True if $network_id is the main network, or if not running Multisite.
函数位置
File: wp-includes/functions.php.
函数源码
function is_main_network( $network_id = null ) {
if ( ! is_multisite() ) {
return true;
}
if ( null === $network_id ) {
$network_id = get_current_network_id();
}
$network_id = (int) $network_id;
return ( get_main_network_id() === $network_id );
}
源码链接
变更日志
| Version | Description |
|---|---|
| 3.7.0 | Introduced. |

