Title: Developing for a multisite network
Published: 11 May 2024
Last modified: 26 March 2025

---

[Home](https://learn.wordpress.org)[Courses](https://learn.wordpress.org/courses/)
[Beginner WordPress Developer](https://learn.wordpress.org/course/beginner-wordpress-developer/)
Developing for a multisite network

 [ Exit Course ](https://learn.wordpress.org/course/beginner-wordpress-developer/)

 1.   a.  [   WordPress and web servers  ](https://learn.wordpress.org/lesson/wordpress-and-web-servers/)
         [Preview](https://learn.wordpress.org/lesson/wordpress-and-web-servers/)
      b.  [   The WordPress file structure  ](https://learn.wordpress.org/lesson/the-wordpress-file-structure/)
         [Preview](https://learn.wordpress.org/lesson/the-wordpress-file-structure/)
      c.  [   The WordPress database  ](https://learn.wordpress.org/lesson/the-wordpress-database/)
         [Preview](https://learn.wordpress.org/lesson/the-wordpress-database/)
      d.  [   Permalinks, rewriting urls on Apache and Nginx  ](https://learn.wordpress.org/lesson/permalinks-rewriting-urls-on-apache-and-nginx/)
         [Preview](https://learn.wordpress.org/lesson/permalinks-rewriting-urls-on-apache-and-nginx/)
      e.  [   Front-end page request  ](https://learn.wordpress.org/lesson/front-end-page-request/)
         [Preview](https://learn.wordpress.org/lesson/front-end-page-request/)
      f.  [   Admin page request  ](https://learn.wordpress.org/lesson/admin-page-request/)
         [Preview](https://learn.wordpress.org/lesson/admin-page-request/)
 2.   6 lessons
 3.   a.  [   Local development environment  ](https://learn.wordpress.org/lesson/local-development-environment/)
         [Preview](https://learn.wordpress.org/lesson/local-development-environment/)
      b.  [   WordPress Installation  ](https://learn.wordpress.org/lesson/wordpress-installation/)
         [Preview](https://learn.wordpress.org/lesson/wordpress-installation/)
      c.  [   Code editor  ](https://learn.wordpress.org/lesson/code-editor/) [Preview](https://learn.wordpress.org/lesson/code-editor/)
      d.  [   Other useful development tools  ](https://learn.wordpress.org/lesson/other-useful-development-tools/)
         [Preview](https://learn.wordpress.org/lesson/other-useful-development-tools/)
 4.   4 lessons
 5.   a.  [   HTML  ](https://learn.wordpress.org/lesson/html/) [Preview](https://learn.wordpress.org/lesson/html/)
      b.  [   CSS  ](https://learn.wordpress.org/lesson/css/) [Preview](https://learn.wordpress.org/lesson/css/)
      c.  [   JavaScript  ](https://learn.wordpress.org/lesson/javascript/) [Preview](https://learn.wordpress.org/lesson/javascript/)
      d.  [   PHP  ](https://learn.wordpress.org/lesson/php/) [Preview](https://learn.wordpress.org/lesson/php/)
      e.  [   MySQL  ](https://learn.wordpress.org/lesson/mysql/) [Preview](https://learn.wordpress.org/lesson/mysql/)
 6.   5 lessons
 7.   a.  [   WordPress Hooks  ](https://learn.wordpress.org/lesson/wordpress-hooks/) 
         [Preview](https://learn.wordpress.org/lesson/wordpress-hooks/)
      b.  [   Action Hooks  ](https://learn.wordpress.org/lesson/action-hooks/) [Preview](https://learn.wordpress.org/lesson/action-hooks/)
      c.  [   Filter Hooks  ](https://learn.wordpress.org/lesson/filter-hooks/) [Preview](https://learn.wordpress.org/lesson/filter-hooks/)
      d.  [   Working with hooks  ](https://learn.wordpress.org/lesson/working-with-hooks/)
         [Preview](https://learn.wordpress.org/lesson/working-with-hooks/)
 8.   4 lessons
 9.   a.  [   Introduction to themes for developers  ](https://learn.wordpress.org/lesson/what-is-a-theme/)
         [Preview](https://learn.wordpress.org/lesson/what-is-a-theme/)
      b.  [   Theme structure  ](https://learn.wordpress.org/lesson/theme-structure/) 
         [Preview](https://learn.wordpress.org/lesson/theme-structure/)
      c.  [   Main stylesheet  ](https://learn.wordpress.org/lesson/main-stylesheet/) 
         [Preview](https://learn.wordpress.org/lesson/main-stylesheet/)
      d.  [   Templates  ](https://learn.wordpress.org/lesson/templates-3/) [Preview](https://learn.wordpress.org/lesson/templates-3/)
      e.  [   Global settings and styles  ](https://learn.wordpress.org/lesson/global-settings-and-styles/)
         [Preview](https://learn.wordpress.org/lesson/global-settings-and-styles/)
      f.  [   Create Block Theme plugin  ](https://learn.wordpress.org/lesson/create-block-theme-plugin/)
         [Preview](https://learn.wordpress.org/lesson/create-block-theme-plugin/)
 10.  6 lessons
 11.  a.  [   What is a plugin?  ](https://learn.wordpress.org/lesson/what-is-a-plugin/)
         [Preview](https://learn.wordpress.org/lesson/what-is-a-plugin/)
      b.  [   Plugin requirements  ](https://learn.wordpress.org/lesson/plugin-requirements/)
         [Preview](https://learn.wordpress.org/lesson/plugin-requirements/)
      c.  [   Custom post types  ](https://learn.wordpress.org/lesson/custom-post-types/)
         [Preview](https://learn.wordpress.org/lesson/custom-post-types/)
      d.  [   Custom taxonomies  ](https://learn.wordpress.org/lesson/custom-taxonomies/)
         [Preview](https://learn.wordpress.org/lesson/custom-taxonomies/)
      e.  [   Custom post type data  ](https://learn.wordpress.org/lesson/custom-post-type-data/)
         [Preview](https://learn.wordpress.org/lesson/custom-post-type-data/)
      f.  [   Enqueuing CSS or JavaScript  ](https://learn.wordpress.org/lesson/enqueuing-css-or-javascript/)
         [Preview](https://learn.wordpress.org/lesson/enqueuing-css-or-javascript/)
 12.  6 lessons
 13.  a.  [   Setting up your block development environment  ](https://learn.wordpress.org/lesson/setting-up-your-block-development-environment/)
         [Preview](https://learn.wordpress.org/lesson/setting-up-your-block-development-environment/)
      b.  [   Scaffolding a new block  ](https://learn.wordpress.org/lesson/scaffolding-a-new-block/)
         [Preview](https://learn.wordpress.org/lesson/scaffolding-a-new-block/)
      c.  [   Building your first block  ](https://learn.wordpress.org/lesson/building-your-first-block/)
         [Preview](https://learn.wordpress.org/lesson/building-your-first-block/)
      d.  [   Block functionality  ](https://learn.wordpress.org/lesson/block-functionality/)
         [Preview](https://learn.wordpress.org/lesson/block-functionality/)
      e.  [   Block attributes  ](https://learn.wordpress.org/lesson/block-attributes-2/)
         [Preview](https://learn.wordpress.org/lesson/block-attributes-2/)
      f.  [   Block supports and styles  ](https://learn.wordpress.org/lesson/block-supports-and-styles/)
         [Preview](https://learn.wordpress.org/lesson/block-supports-and-styles/)
      g.  [   Static vs dynamic blocks  ](https://learn.wordpress.org/lesson/static-vs-dynamic-blocks/)
         [Preview](https://learn.wordpress.org/lesson/static-vs-dynamic-blocks/)
 14.  7 lessons
 15.  a.  [   The WordPress REST API  ](https://learn.wordpress.org/lesson/the-wordpress-rest-api/)
         [Preview](https://learn.wordpress.org/lesson/the-wordpress-rest-api/)
      b.  [   Using the WordPress REST API  ](https://learn.wordpress.org/lesson/using-the-wordpress-rest-api/)
         [Preview](https://learn.wordpress.org/lesson/using-the-wordpress-rest-api/)
      c.  [   Interacting with the WordPress REST API  ](https://learn.wordpress.org/lesson/interacting-with-the-wordpress-rest-api/)
         [Preview](https://learn.wordpress.org/lesson/interacting-with-the-wordpress-rest-api/)
      d.  [   Extending the WordPress REST API  ](https://learn.wordpress.org/lesson/extending-the-wordpress-rest-api/)
         [Preview](https://learn.wordpress.org/lesson/extending-the-wordpress-rest-api/)
 16.  4 lessons
 17.  a.  [   Securely developing plugins and themes  ](https://learn.wordpress.org/lesson/securely-developing-plugins-and-themes/)
         [Preview](https://learn.wordpress.org/lesson/securely-developing-plugins-and-themes/)
      b.  [   Fixing common security vulnerabilities  ](https://learn.wordpress.org/lesson/fixing-common-security-vulnerabilities/)
         [Preview](https://learn.wordpress.org/lesson/fixing-common-security-vulnerabilities/)
      c.  [   Tools to detect security vulnerabilities  ](https://learn.wordpress.org/lesson/tools-to-detect-security-vulnerabilities/)
         [Preview](https://learn.wordpress.org/lesson/tools-to-detect-security-vulnerabilities/)
 18.  3 lessons
 19.  a.  [   What is Internationalization?  ](https://learn.wordpress.org/lesson/what-is-internationalization/)
         [Preview](https://learn.wordpress.org/lesson/what-is-internationalization/)
      b.  [   The commonly used Internationalization functions  ](https://learn.wordpress.org/lesson/the-commonly-used-internationalization-functions/)
         [Preview](https://learn.wordpress.org/lesson/the-commonly-used-internationalization-functions/)
 20.  2 lessons
 21.  a.  [   Setting up a WordPress multisite network  ](https://learn.wordpress.org/lesson/setting-up-a-wordpress-multisite-network/)
         [Preview](https://learn.wordpress.org/lesson/setting-up-a-wordpress-multisite-network/)
      b.  [   Managing a WordPress multisite network  ](https://learn.wordpress.org/lesson/managing-a-wordpress-multisite-network/)
         [Preview](https://learn.wordpress.org/lesson/managing-a-wordpress-multisite-network/)
      c.  [   Advanced multisite management  ](https://learn.wordpress.org/lesson/advanced-multisite-management/)
         [Preview](https://learn.wordpress.org/lesson/advanced-multisite-management/)
      d.  [   Developing for a multisite network  ](https://learn.wordpress.org/lesson/developing-for-a-multisite-network/)
         [Preview](https://learn.wordpress.org/lesson/developing-for-a-multisite-network/)
      e.  [   Building plugins and themes that support multisite  ](https://learn.wordpress.org/lesson/building-plugins-and-themes-that-support-multisite/)
         [Preview](https://learn.wordpress.org/lesson/building-plugins-and-themes-that-support-multisite/)
 22.  5 lessons
 23.  a.  [   The built-in WordPress debugging options  ](https://learn.wordpress.org/lesson/the-built-in-wordpress-debugging-options/)
         [Preview](https://learn.wordpress.org/lesson/the-built-in-wordpress-debugging-options/)
      b.  [   Examining the state of your PHP code  ](https://learn.wordpress.org/lesson/examining-the-state-of-your-php-code/)
         [Preview](https://learn.wordpress.org/lesson/examining-the-state-of-your-php-code/)
      c.  [   Examining the state of your JavaScript code  ](https://learn.wordpress.org/lesson/examining-the-state-of-your-javascript-code/)
         [Preview](https://learn.wordpress.org/lesson/examining-the-state-of-your-javascript-code/)
      d.  [   Useful debugging plugins  ](https://learn.wordpress.org/lesson/useful-debugging-plugins/)
         [Preview](https://learn.wordpress.org/lesson/useful-debugging-plugins/)
 24.  4 lessons
 25.  a.  [   Quiz time  ](https://learn.wordpress.org/lesson/quiz-time/)
 26.  1 lesson, 1 quiz
 27.  a.  [   Time to test your skills  ](https://learn.wordpress.org/lesson/time-to-test-your-skills/)
 28.  1 lesson, 1 quiz
 29.  a.  [   Test your knowledge  ](https://learn.wordpress.org/lesson/test-your-knowledge/)
 30.  1 lesson, 1 quiz

### An introduction to WordPress multisite

# Developing for a multisite network

WordPress core includes a set of functions and hooks that control certain aspects
of the network, or individual sites on the network.

In this lesson, you’ll learn about multisite-specific function naming conventions
to be aware of, and then dive into some useful multisite-specific functions and 
hooks you can use. Finally, you’ll learn about developing for individual sites in
a network, as well as where to go for more information about multisite functions
and hooks.

## Note on naming conventions

There are a couple of different naming conventions used in the WordPress codebase
when it comes to multisite.

WordPress multisite was originally known as [WordPress MU](https://codex.wordpress.org/WordPress_MU)(
or WordPress multi-user), and many multisite-related functions and hooks use the`
wpmu_` prefix.

Additionally, some functions are named based on the old terminology which described
multiple “blogs” on a “site”. This has since been updated to describe multiple “
sites” on a “network” instead, but some old terminology still lives on in some function
names.

## Useful functions

When you’re developing a product to support a multisite network, there are some 
useful internal functions worth knowing.

The first is the [is_multsite](https://developer.wordpress.org/reference/functions/is_multisite/)
function. This function will return true if multisite is enabled, and is probably
the most widely used function related to multisite. If you do a search through the
WordPress codebase for uses of the `is_multsite` function, you’ll see that it’s 
used in a number of places, to either perform specific tasks in the context of a
multisite network or to restrict functionality only to multisite networks.

There are also some common functions that are useful when developing administration
interfaces for a multisite network:

 * [is_super_admin](https://developer.wordpress.org/reference/functions/is_super_admin/)
   can be used to check if the currently logged-in user is a Network Administrator
   on the network.
 * [is_network_admin](https://developer.wordpress.org/reference/functions/is_network_admin/)
   is the multisite equivalent of the `is_admin` function and determines whether
   the current request is for the network administrative interface.
 * [network_admin_url](https://developer.wordpress.org/reference/functions/network_admin_url/)
   is the multisite equivalent of the `admin_url` function and allows you to create
   URLs relative to the admin area of the network. This is useful for redirecting
   to different areas of the network admin dashboard.

When working with site content, there are some functions that are widely used.

[is_main_site](https://developer.wordpress.org/reference/functions/is_main_site/)
determines whether the current site is the main site of the current network or not.

Next, there is the get_sites function, which will return a list of sites matching
the requested arguments.

Then there is [switch_to_blog](https://developer.wordpress.org/reference/functions/switch_to_blog/),
which allows you to switch to a different site in the network, [restore_current_blog](https://developer.wordpress.org/reference/functions/restore_current_blog/)
which restores the current site after you’ve switched to a different site and [get_current_blog_id](https://developer.wordpress.org/reference/functions/get_current_blog_id/),
which returns the ID of the current site.

Using these functions, you can perform actions across the network.

For example, let’s say you wanted to create a function that updated an option on
a specific site on the network.

    ```php
    function update_site_option( $site_id,  $option_name, $option_value ) {
        switch_to_blog( $site_id );
        update_option(  $option_name, $option_value );
        restore_current_blog();
    }
    ```

However, if you wanted to extend that to update the same option across all sites,
you could use the get_sites function, and loop through all sites on the network.

    ```php
    function update_option_on_all_sites( $option_name, $option_value ) {
        $sites = get_sites();
        foreach ( $sites as $site ) {
            switch_to_blog( $site->blog_id );
            update_option( 'my_option', 'my_value' );
            restore_current_blog();
        }
    }
    ```

You could also use the [update_blog_option](https://developer.wordpress.org/reference/functions/update_blog_option/)
function to update an option on a specific site, without having to switch to that
site.

    ```php
    function update_option_on_all_sites( $option_name, $option_value ) {
        $sites = get_sites();
        foreach ( $sites as $site ) {
            update_blog_option( $site->blog_id, $option_name, $option_value );
        }
    }
    ```

When developing multisite plugins, there is the [is_network_only_plugin](https://developer.wordpress.org/reference/functions/is_network_only_plugin/)
function. This is a plugin specific function that checks for the “Network: true”
in the plugin header to see if this should be activated only as a network wide plugin.
This is useful if you want to restrict a plugin to only be activated on a network,
and not on individual sites.

## Useful hooks

There are also a couple of useful hooks that you can use when developing for multisite.

The first is the [network_admin_menu](https://developer.wordpress.org/reference/hooks/network_admin_menu/)
hook, which allows you to add menu items to the network admin dashboard. This is
useful if you want to add a custom menu item to the network admin dashboard.

The second is the [network_admin_notices](https://developer.wordpress.org/reference/hooks/network_admin_notices/)
hook, which allows you to add notices to the network admin dashboard. This can be
used to display a notice to network admins, in the same way that admin_notices is
used for single-site notices.

[signup_blogform](https://developer.wordpress.org/reference/hooks/signup_blogform/)
is a filter that allows you to modify the signup form for new sites. You can use
this to add additional fields to the signup form.

[wp_initialize_site](https://developer.wordpress.org/reference/hooks/wp_initialize_site/)
is an action that is fired when a new site is created. This is useful if you want
to perform actions when a new site is created, for example if you wanted to assign
a custom top level domain to a sub-site.

## Developing for individual sites in a network

When you are rendering any content in the scope of a single site on the network,
WordPress core is clever enough to know that you are working inside the scope of
that site.

This means that any functions that you use to retrieve information, such as get_bloginfo,
get_option, get_posts, or get_post_meta, and any functions you might use to add 
or update information, like update_option, wp_insert_post or update_post_meta, will
get, add or update the correct tables for the site that you are currently working
with.

Additionally, if you use functions like `register_post_type` or `register_taxonomy`,
these will be registered for the current site only.

## Further reading

For a full list of all WordPress multisite-related functions and hooks, check out
the [Multisite Package Category](https://developer.wordpress.org/reference/package/multisite/)
in the WordPress developer reference.

 This is a preview lesson

Register or sign in to take this lesson.

 [ Take course ](https://learn.wordpress.org/course/beginner-wordpress-developer/)

 [ Sign in ](https://login.wordpress.org/?redirect_to=https%3A%2F%2Flearn.wordpress.org%2Flesson%2Fdeveloping-for-a-multisite-network%2F&locale=en_US)

##  Suggestions

 Found a typo, grammar error or outdated screenshot? [Contact us](https://learn.wordpress.org/report-content-feedback/).