Title: is_main_site
Published: April 25, 2014
Last modified: February 24, 2026

---

# is_main_site( int $site_id = null, int $network_id = null ): bool

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/is_main_site/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/is_main_site/?output_format=md#return)
 * [More Information](https://developer.wordpress.org/reference/functions/is_main_site/?output_format=md#more-information)
 * [Source](https://developer.wordpress.org/reference/functions/is_main_site/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/is_main_site/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/is_main_site/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/is_main_site/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/is_main_site/?output_format=md#wp--skip-link--target)

Determines whether a site is the main site of the current network.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/is_main_site/?output_format=md#parameters)󠁿

 `$site_id`intoptional

Site ID to test. Defaults to current site.

Default:`null`

`$network_id`intoptional

Network ID of the network to check for.
 Defaults to current network.

Default:`null`

## 󠀁[Return](https://developer.wordpress.org/reference/functions/is_main_site/?output_format=md#return)󠁿

 bool True if $site_id is the main site of the network, or if not running Multisite.

## 󠀁[More Information](https://developer.wordpress.org/reference/functions/is_main_site/?output_format=md#more-information)󠁿

Replaces function `is_main_blog()`, deprecated since 3.0.0. (wp-includes/ms-deprecated.
php)

## 󠀁[Source](https://developer.wordpress.org/reference/functions/is_main_site/?output_format=md#source)󠁿

    ```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;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/functions.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/functions.php#L6410)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/functions.php#L6410-L6422)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/is_main_site/?output_format=md#related)󠁿

| Uses | Description | 
| [get_main_site_id()](https://developer.wordpress.org/reference/functions/get_main_site_id/)`wp-includes/functions.php` |

Gets the main site ID.

  | 
| [is_multisite()](https://developer.wordpress.org/reference/functions/is_multisite/)`wp-includes/load.php` |

Determines whether Multisite is enabled.

  | 
| [get_current_blog_id()](https://developer.wordpress.org/reference/functions/get_current_blog_id/)`wp-includes/load.php` |

Retrieves the current site ID.

  |

[Show 1 more](https://developer.wordpress.org/reference/functions/is_main_site/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/is_main_site/?output_format=md#)

| Used by | Description | 
| [wp_schedule_update_user_counts()](https://developer.wordpress.org/reference/functions/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()](https://developer.wordpress.org/reference/classes/wp_ms_sites_list_table/site_states/)`wp-admin/includes/class-wp-ms-sites-list-table.php` |

Determines whether to output comma-separated site states.

  | 
| [WP_Site_Health_Auto_Updates::test_wp_version_check_attached()](https://developer.wordpress.org/reference/classes/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()](https://developer.wordpress.org/reference/functions/delete_expired_transients/)`wp-includes/option.php` |

Deletes all expired transients.

  | 
| [wp_load_press_this()](https://developer.wordpress.org/reference/functions/wp_load_press_this/)`wp-admin/press-this.php` |  | 
| [_wp_upload_dir()](https://developer.wordpress.org/reference/functions/_wp_upload_dir/)`wp-includes/functions.php` |

A non-filtered, non-cached version of [wp_upload_dir()](https://developer.wordpress.org/reference/functions/wp_upload_dir/) that doesn’t check the path.

  | 
| [WP_MS_Sites_List_Table::handle_row_actions()](https://developer.wordpress.org/reference/classes/wp_ms_sites_list_table/handle_row_actions/)`wp-admin/includes/class-wp-ms-sites-list-table.php` |

Generates and displays row action links.

  | 
| [WP_MS_Sites_List_Table::column_cb()](https://developer.wordpress.org/reference/classes/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()](https://developer.wordpress.org/reference/functions/wp_should_upgrade_global_tables/)`wp-admin/includes/upgrade.php` |

Determine if global tables should be upgraded.

  | 
| [WP_Automatic_Updater::run()](https://developer.wordpress.org/reference/classes/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()](https://developer.wordpress.org/reference/functions/avoid_blog_page_permalink_collision/)`wp-admin/includes/ms.php` |

Avoids a collision between a site slug and a permalink slug.

  | 
| [wpmu_delete_blog()](https://developer.wordpress.org/reference/functions/wpmu_delete_blog/)`wp-admin/includes/ms.php` |

Deletes a site.

  | 
| [wp_upgrade()](https://developer.wordpress.org/reference/functions/wp_upgrade/)`wp-admin/includes/upgrade.php` |

Runs WordPress Upgrade functions.

  | 
| [WP_Rewrite::rewrite_rules()](https://developer.wordpress.org/reference/classes/wp_rewrite/rewrite_rules/)`wp-includes/class-wp-rewrite.php` |

Constructs rewrite matches and queries from permalink structure.

  | 
| [wp_schedule_update_network_counts()](https://developer.wordpress.org/reference/functions/wp_schedule_update_network_counts/)`wp-includes/ms-functions.php` |

Schedules update of the network-wide counts for the current network.

  | 
| [get_dirsize()](https://developer.wordpress.org/reference/functions/get_dirsize/)`wp-includes/functions.php` |

Gets the size of a directory.

  | 
| [maybe_redirect_404()](https://developer.wordpress.org/reference/functions/maybe_redirect_404/)`wp-includes/ms-functions.php` |

Corrects 404 redirects when NOBLOGREDIRECT is defined.

  | 
| [is_main_blog()](https://developer.wordpress.org/reference/functions/is_main_blog/)`wp-includes/ms-deprecated.php` |

Deprecated functionality to determine if the current site is the main site.

  |

[Show 13 more](https://developer.wordpress.org/reference/functions/is_main_site/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/is_main_site/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/is_main_site/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.9.0](https://developer.wordpress.org/reference/since/4.9.0/) | The `$network_id` parameter was added. | 
| [3.0.0](https://developer.wordpress.org/reference/since/3.0.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/is_main_site/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/functions/is_main_site/?output_format=md#comment-content-1398)
 2.   [Codex](https://profiles.wordpress.org/codex/)  [  10 years ago  ](https://developer.wordpress.org/reference/functions/is_main_site/#comment-1398)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fis_main_site%2F%23comment-1398)
    Vote results for this note: -1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fis_main_site%2F%23comment-1398)
 4. **Example**
 5.     ```php
        if ( is_main_site( $blog_id ) ) {
          // display something special for the main site.
        }
        ```
    
 6.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fis_main_site%2F%3Freplytocom%3D1398%23feedback-editor-1398)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fis_main_site%2F)
before being able to contribute a note or feedback.