In WordPress, is_multisite() returns true when the install is a Multisite network, which means many sites share one WordPress. It returns false for a normal single site.
Use it to run code that makes sense only on a network, such as switching between sites or checking network settings.
Syntax
Use it as the test of an if statement.
WordPress
if ( is_multisite() ) {
// code for the true path
} else {
// code for the false path
}
Call
What it does
is_multisite()
True on a network install.
! is_multisite()
True on a single site.
is_main_site()
Ask next if this is the first site of the network.
Turn it on by setting WP_ALLOW_MULTISITE and then using Tools > Network Setup.
Full declaration
WordPress
is_multisite(): bool
Parameters
Parameter
Description
None
This function takes no parameters.
Return Value
Return Value
Description
bool
true if Multisite is enabled, otherwise false.
WordPress Examples
Three short theme examples. Each one shows what prints on the true path and the false path.
Example 1 — Print the install type
Show whether the site is a network.
WordPress
<?php if ( is_multisite() ) {
echo 'This is a Multisite network.';
} else {
echo 'This is a single site.';
} ?>
Output
On a network (true):
This is a Multisite network.
On a normal site (false):
This is a single site.
How It Works
is_multisite() checks the install type.
The if branch runs on a network.
The else branch runs on a single site.
Example 2 — Call network functions safely
Use a network function only when it exists.
WordPress
<?php if ( is_multisite() ) {
echo 'Current site ID: ' . get_current_blog_id();
} ?>
Output
On a network (true):
Current site ID: 2
On a single site (false):
(nothing is printed)
How It Works
get_current_blog_id() returns the ID of the site.
We call it only on a network.
This keeps single-site installs simple.
Example 3 — Loop through sites
Network code that visits each site.
WordPress
<?php if ( is_multisite() ) {
foreach ( get_sites() as $site ) {
echo $site->blogname . '<br>';
}
} ?>
Output
On a network (true):
Main Site
Blog Two
Blog Three
On a single site (false):
(nothing is printed)
How It Works
get_sites() returns the sites of the network.
The loop prints each site name.
The whole block is skipped on a single site.
Frequently Asked Questions
It returns true or false (a bool). Use it inside an if statement.
Add define( 'WP_ALLOW_MULTISITE', true ); to wp-config.php, then follow Tools > Network Setup.
Yes. It checks the install, so it is true on the main site and on every sub-site.