is_main_site
Determine whether a site is the main site of the current network.
Description
is_main_site( (null) $site_id = null );
Parameters (1)
- 0. $site_id — Optional. (null) =>
null
- Site ID to test. Defaults to current site.
Usage
if ( !function_exists( 'is_main_site' ) ) { require_once ABSPATH . WPINC . '/functions.php'; } // Optional. Site ID to test. Defaults to current site. $site_id = null; // NOTICE! Understand what this does before running. $result = is_main_site($site_id);
Defined (1)
The function is defined in the following location(s).
- /wp-includes/functions.php
- function is_main_site( $site_id = null ) {
- if ( ! is_multisite() )
- return true;
- if ( ! $site_id )
- $site_id = get_current_blog_id();
- return (int) $site_id === (int) get_network()->site_id;
- }