The is_multisite() WordPress PHP function checks if a WordPress installation is running on Multisite mode.
Usage
$is_multisite_enabled = is_multisite();
Parameters
- None
More information
See WordPress Developer Resources: is_multisite()
Examples
Check if Multisite is enabled
In this example, we check if Multisite is enabled and display a message accordingly.
if (is_multisite()) { echo 'Multisite is enabled!'; } else { echo 'Multisite is not enabled.'; }
Custom function to get site count
In this example, we create a custom function that returns the number of sites in a Multisite installation if it is enabled.
function get_site_count() { if (is_multisite()) { $site_count = get_blog_count(); return $site_count; } else { return 'Multisite is not enabled.'; } } echo get_site_count();
Conditional loading of a plugin
In this example, we only load a plugin if Multisite is enabled.
if (is_multisite()) { include_once('my-multisite-plugin.php'); }
Custom function to get a list of site admins
In this example, we create a custom function that returns a list of site administrators if Multisite is enabled.
function get_site_admins() { if (is_multisite()) { $site_admins = get_super_admins(); return $site_admins; } else { return 'Multisite is not enabled.'; } } $admins = get_site_admins(); print_r($admins);
Show different widgets based on Multisite status
In this example, we display a different set of widgets if Multisite is enabled.
if (is_multisite()) { dynamic_sidebar('multisite-sidebar'); } else { dynamic_sidebar('single-site-sidebar'); }