is_multisite(): bool
- Since
- 3.0.0
- Source
wp-includes/load.php:1448
Reports whether the current WordPress install has the Multisite feature turned on, based on the MULTISITE, SUBDOMAIN_INSTALL, VHOST, and SUNRISE constants. It does not check a database option, so it stays accurate even before the database is fully loaded. Use it to branch code that relies on network-only functions like switch_to_blog() or get_sites().
Compatibility
- WordPress
- since 3.0.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Return value
bool- True if Multisite is enabled, false otherwise.
Code examples
Every example is editable and runs in a real WordPress booted in your browser by WordPress Playground. Press Run, then edit the code: clicking away re-runs it. Nothing is sent anywhere until you do.
Check if the current install is a multisite network
A minimal check useful when deciding whether to load network-specific admin code.
$network_enabled = is_multisite();
echo esc_html( 'Multisite enabled: ' . ( $network_enabled ? 'yes' : 'no' ) );On a fresh single-site install this prints "no" because none of the underlying constants are defined.
Branch between network-wide and single-site reporting
A plugin dashboard widget that shows network site counts on Multisite and post counts otherwise.
if ( is_multisite() ) {
$sites = get_sites( array( 'number' => 5 ) );
echo esc_html( 'Network has ' . count( $sites ) . ' sites (showing up to 5).' );
} else {
$post_counts = wp_count_posts();
echo esc_html( 'Single site install with ' . $post_counts->publish . ' published posts.' );
}The sandbox is a single-site install, so this prints the published post count from the baseline fixtures.
Common problems and fixes · 3
- Why does is_multisite() return true on a site I never ran the network setup on?
- Can I use is_multisite() to check if one particular site in the network is active or archived?
- Why did wrapping my code in is_multisite() break it on my single-site install?
Why does is_multisite() return true on a site I never ran the network setup on?
Can I use is_multisite() to check if one particular site in the network is active or archived?
Why did wrapping my code in is_multisite() break it on my single-site install?
return false whenever none of the four constants are defined, any code inside an if ( is_multisite() ) block simply never runs on a normal single-site install. That is expected, but it's a common surprise when testing multisite-only features locally.Alternatives and related functions
is_main_site- When you already know the install is Multisite and need to know if the current site is the network's primary site.
get_current_blog_id- When you need the numeric ID of the site currently being served, rather than just a yes/no about Multisite.
switch_to_blog- When you need to run queries or template code in the context of a different site on the network.
wp_is_large_network- When you need to know if the network has grown past a size threshold, to skip expensive network-wide queries.
Performance profile
How much work a call to is_multisite() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Trivial
- Scaling
- Constant
- Instructions
- 4–9
- Plugin surface
- None
- Called by
- 50
Touches nothing outside its own arguments.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 12.
Nothing here hands control to plugin code.
50 places in core call this, so the cost is paid more often than your own code shows.
What one call costs · 1 distinct outcome
One number would be a lie: the work depends on which branch runs. These are every distinct cost is_multisite() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 4–9 | none |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 12 instructions, 4–9 executed per call, 4 branches. The work does not change between versions.
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Used by · 50
- Plugin_Installer_Skin::after()Performs an action following a plugin install.
- Plugin_Upgrader::bulk_upgrade()Upgrades several plugins at once.
- Theme_Upgrader::bulk_upgrade()Upgrades several themes at once.
- WP_Admin_Bar::initialize()Initializes the admin bar.
- WP_Customize_Manager::enqueue_control_scripts()Enqueues scripts for customize controls.
- WP_Customize_Manager::register_controls()Registers some default controls.
- WP_Customize_Theme_Control::content_template()Render a JS template for theme display.
- WP_Customize_Themes_Panel::content_template()An Underscore (JS) template for this panel's content (but not its container).
- WP_Customize_Themes_Section::render_template()Renders a themes section as a JS template.
- WP_Date_Query::validate_column()Validates a column name parameter.
- WP_Debug_Data::get_wp_core()Gets the WordPress core section of the debug data.
- WP_Debug_Data::get_wp_paths_sizes()Gets the WordPress paths and sizes section of the debug data.
Show all 50
- WP_Fatal_Error_Handler::display_default_error_template()Displays the default PHP error template.
- WP_Fatal_Error_Handler::handle()Runs the shutdown handler.
- WP_Importer::set_blog()
- WP_Object_Cache::__construct()Sets up object properties.
- WP_Plugin_Dependencies::check_plugin_dependencies_during_ajax()Checks plugin dependencies after a plugin is installed via AJAX.
- WP_Plugin_Dependencies::display_admin_notice_for_unmet_dependencies()Displays an admin notice if dependencies are not installed.
- WP_Plugins_List_Table::__construct()Constructor.
- WP_Plugins_List_Table::add_dependencies_to_dependent_plugin_row()Prints a list of other plugins that the plugin depends on.
- WP_Plugins_List_Table::display_rows()Generates the list table rows.
- WP_Plugins_List_Table::get_bulk_actions()
- WP_Plugins_List_Table::no_items()
- WP_Plugins_List_Table::prepare_items()
- WP_Plugins_List_Table::single_row()
- WP_REST_Application_Passwords_Controller::get_user()Gets the requested user.
- WP_REST_Attachments_Controller::check_upload_size()Determine if uploaded file exceeds space quota on multisite.
- WP_REST_Plugins_Controller::check_read_permission()Checks if the given plugin can be viewed by the current user.
- WP_REST_Plugins_Controller::get_collection_params()Retrieves the query params for the collections.
- WP_REST_Plugins_Controller::get_item_schema()Retrieves the plugin's schema, conforming to JSON Schema.
- WP_REST_Plugins_Controller::handle_plugin_status()Handle updating a plugin's status.
- WP_REST_Plugins_Controller::plugin_status_permission_check()Handle updating a plugin's status.
- WP_REST_Plugins_Controller::register_routes()Registers the routes for the plugins controller.
- WP_REST_Site_Health_Controller::register_routes()Registers API routes.
- WP_REST_Users_Controller::check_role_update()Determines if the current user is allowed to make the desired roles change.
- WP_REST_Users_Controller::create_item()Creates a single user.
- WP_REST_Users_Controller::delete_item()Deletes a single user.
- WP_REST_Users_Controller::get_user()Get the user, if the ID is valid.
- WP_Recovery_Mode::is_network_plugin()Checks whether the given extension a network activated plugin.
- WP_Rewrite::rewrite_rules()Constructs rewrite matches and queries from permalink structure.
- WP_Roles::get_roles_data()Gets the available roles data.
- WP_Site_Health::get_test_plugin_version()Tests if plugins are outdated, or unnecessary.
- WP_Site_Health::get_test_theme_version()Tests if themes are outdated, or unnecessary.
- WP_Site_Health::should_suggest_persistent_object_cache()Determines whether to suggest using a persistent object cache.
- WP_Site_Health_Auto_Updates::test_wp_version_check_attached()Checks if updates are intercepted by a filter.
- WP_Theme::get_allowed_on_site()Returns array of stylesheet names of themes allowed on the site.
- WP_Theme::is_allowed()Determines whether the theme is allowed (multisite only).
- WP_Theme::network_disable_theme()Disables a theme for all sites on the current network.
- WP_Theme::network_enable_theme()Enables a theme for all sites on the current network.
- WP_Themes_List_Table::display_rows()Generates the list table rows.
Source code
function is_multisite() { if ( defined( 'MULTISITE' ) ) { return MULTISITE; } if ( defined( 'SUBDOMAIN_INSTALL' ) || defined( 'VHOST' ) || defined( 'SUNRISE' ) ) { return true; } return false;}Changelog
Introduced in 3.0.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.0.4 tag, from
src/wp-includes/load.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.