On this page
is_main_site( int $site_id = null, int $network_id = null ): bool
Determines whether a site is the main site of the current network.
Parameters
$site_idint Optional-
Site ID to test. Defaults to current site.
Default:
null $network_idint Optional-
Network ID of the network to check for.
Defaults to current network.Default:
null
Return
bool True if $site_id is the main site of the network, or if not running Multisite.
More Information
Replaces function is_main_blog(), deprecated since 3.0.0. (wp-includes/ms-deprecated.php)
Source
File: wp-includes/functions.php. View all references
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;
}
Related
Uses
| Uses | Description |
|---|---|
| get_main_site_id() wp-includes/functions.php | Gets the main site ID. |
| is_multisite() wp-includes/load.php | If Multisite is enabled. |
| get_current_blog_id() wp-includes/load.php | Retrieve the current site ID. |
Used By
| Used By | Description |
|---|---|
| wp_schedule_update_user_counts() wp-includes/user.php | Schedules a recurring recalculation of the total count of users. |
| WP_MS_Sites_List_Table::site_states() wp-admin/includes/class-wp-ms-sites-list-table.php | Maybe output comma-separated site states. |
| WP_Site_Health_Auto_Updates::test_wp_version_check_attached() wp-admin/includes/class-wp-site-health-auto-updates.php | Checks if updates are intercepted by a filter. |
| delete_expired_transients() wp-includes/option.php | Deletes all expired transients. |
| wp_load_press_this() wp-admin/press-this.php | |
| _wp_upload_dir() wp-includes/functions.php | A non-filtered, non-cached version of wp_upload_dir() that doesn’t check the path. |
| WP_MS_Sites_List_Table::column_cb() wp-admin/includes/class-wp-ms-sites-list-table.php | Handles the checkbox column output. |
| wp_should_upgrade_global_tables() wp-admin/includes/upgrade.php | Determine if global tables should be upgraded. |
| WP_Automatic_Updater::run() wp-admin/includes/class-wp-automatic-updater.php | Kicks off the background update process, looping through all pending updates. |
| avoid_blog_page_permalink_collision() wp-admin/includes/ms.php | Avoids a collision between a site slug and a permalink slug. |
| wpmu_delete_blog() wp-admin/includes/ms.php | Delete a site. |
| wp_upgrade() wp-admin/includes/upgrade.php | Runs WordPress Upgrade functions. |
| WP_Rewrite::rewrite_rules() wp-includes/class-wp-rewrite.php | Constructs rewrite matches and queries from permalink structure. |
| wp_schedule_update_network_counts() wp-includes/ms-functions.php | Schedules update of the network-wide counts for the current network. |
| maybe_redirect_404() wp-includes/ms-functions.php | Corrects 404 redirects when NOBLOGREDIRECT is defined. |
| get_dirsize() wp-includes/functions.php | Gets the size of a directory. |
| is_main_blog() wp-includes/ms-deprecated.php | Deprecated functionality to determin if the current site is the main site. |
Changelog
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/is_main_site