wppaste
WordPress

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().

Determines whether Multisite is enabled.

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?

The function does not check a database flag, it only checks constants in wp-config.php (or a sunrise.php drop-in). A stray define or a plugin/host that defines SUBDOMAIN_INSTALL, VHOST, or SUNRISE will make it return true regardless of whether Network Setup was ever completed.

Can I use is_multisite() to check if one particular site in the network is active or archived?

No. is_multisite() only reports whether the Multisite feature is switched on for the whole install, it says nothing about an individual site's status.

Why did wrapping my code in is_multisite() break it on my single-site install?

Because the source falls through to 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

Touches nothing outside its own arguments.

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
4–9

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 12.

Plugin surface
None

Nothing here hands control to plugin code.

Called by
50

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.

WhenInstructionsCalls it makes
always4–9none

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

Show all 50

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.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.9.7 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.