Title: network_site_url
Published: April 25, 2014
Last modified: February 24, 2026

---

# network_site_url( string $path, string|null $scheme = null ): string

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/network_site_url/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/functions/network_site_url/?output_format=md#see-also)
 * [Parameters](https://developer.wordpress.org/reference/functions/network_site_url/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/network_site_url/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/network_site_url/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/network_site_url/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/network_site_url/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/network_site_url/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/network_site_url/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/network_site_url/?output_format=md#wp--skip-link--target)

Retrieves the site URL for the current network.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/network_site_url/?output_format=md#description)󠁿

Returns the site URL with the appropriate protocol, ‘https’ if [is_ssl()](https://developer.wordpress.org/reference/functions/is_ssl/)
and ‘http’ otherwise. If $scheme is ‘http’ or ‘https’, [is_ssl()](https://developer.wordpress.org/reference/functions/is_ssl/)
is overridden.

### 󠀁[See also](https://developer.wordpress.org/reference/functions/network_site_url/?output_format=md#see-also)󠁿

 * [set_url_scheme()](https://developer.wordpress.org/reference/functions/set_url_scheme/)

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/network_site_url/?output_format=md#parameters)󠁿

 `$path`stringoptional

Path relative to the site URL. Default empty.

`$scheme`string|nulloptional

Scheme to give the site URL context. Accepts `'http'`, `'https'`, or `'relative'`.

Default:`null`

## 󠀁[Return](https://developer.wordpress.org/reference/functions/network_site_url/?output_format=md#return)󠁿

 string Site URL link with optional path appended.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/network_site_url/?output_format=md#source)󠁿

    ```php
    function network_site_url( $path = '', $scheme = null ) {
    	if ( ! is_multisite() ) {
    		return site_url( $path, $scheme );
    	}

    	$current_network = get_network();

    	if ( 'relative' === $scheme ) {
    		$url = $current_network->path;
    	} else {
    		$url = set_url_scheme( 'http://' . $current_network->domain . $current_network->path, $scheme );
    	}

    	if ( $path && is_string( $path ) ) {
    		$url .= ltrim( $path, '/' );
    	}

    	/**
    	 * Filters the network site URL.
    	 *
    	 * @since 3.0.0
    	 *
    	 * @param string      $url    The complete network site URL including scheme and path.
    	 * @param string      $path   Path relative to the network site URL. Blank string if
    	 *                            no path is specified.
    	 * @param string|null $scheme Scheme to give the URL context. Accepts 'http', 'https',
    	 *                            'relative' or null.
    	 */
    	return apply_filters( 'network_site_url', $url, $path, $scheme );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/link-template.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/link-template.php#L3739)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/link-template.php#L3739-L3768)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/network_site_url/?output_format=md#hooks)󠁿

 [apply_filters( ‘network_site_url’, string $url, string $path, string|null $scheme )](https://developer.wordpress.org/reference/hooks/network_site_url/)

Filters the network site URL.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/network_site_url/?output_format=md#related)󠁿

| Uses | Description | 
| [get_network()](https://developer.wordpress.org/reference/functions/get_network/)`wp-includes/ms-network.php` |

Retrieves network data given a network ID or network object.

  | 
| [set_url_scheme()](https://developer.wordpress.org/reference/functions/set_url_scheme/)`wp-includes/link-template.php` |

Sets the scheme for a URL.

  | 
| [site_url()](https://developer.wordpress.org/reference/functions/site_url/)`wp-includes/link-template.php` |

Retrieves the URL for the current site where WordPress application files (e.g. wp-blog-header.php or the wp-admin/ folder) are accessible.

  | 
| [is_multisite()](https://developer.wordpress.org/reference/functions/is_multisite/)`wp-includes/load.php` |

Determines whether Multisite is enabled.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  |

[Show 2 more](https://developer.wordpress.org/reference/functions/network_site_url/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/network_site_url/?output_format=md#)

| Used by | Description | 
| [retrieve_password()](https://developer.wordpress.org/reference/functions/retrieve_password/)`wp-includes/user.php` |

Handles sending a password retrieval email to a user.

  | 
| [wp_new_user_notification()](https://developer.wordpress.org/reference/functions/wp_new_user_notification/)`wp-includes/pluggable.php` |

Emails login credentials to a newly-registered user.

  | 
| [wp_lostpassword_url()](https://developer.wordpress.org/reference/functions/wp_lostpassword_url/)`wp-includes/general-template.php` |

Returns the URL that allows the user to reset the lost password.

  | 
| [network_admin_url()](https://developer.wordpress.org/reference/functions/network_admin_url/)`wp-includes/link-template.php` |

Retrieves the URL to the admin area for the network.

  | 
| [user_admin_url()](https://developer.wordpress.org/reference/functions/user_admin_url/)`wp-includes/link-template.php` |

Retrieves the URL to the admin area for the current user.

  | 
| [wp_version_check()](https://developer.wordpress.org/reference/functions/wp_version_check/)`wp-includes/update.php` |

Checks WordPress version against the newest version.

  | 
| [redirect_canonical()](https://developer.wordpress.org/reference/functions/redirect_canonical/)`wp-includes/canonical.php` |

Redirects incoming links to the proper URL based on the site url.

  | 
| [wpmu_signup_blog_notification()](https://developer.wordpress.org/reference/functions/wpmu_signup_blog_notification/)`wp-includes/ms-functions.php` |

Sends a confirmation request email to a user when they sign up for a new site. The new site will not become active until the confirmation link is clicked.

  |

[Show 3 more](https://developer.wordpress.org/reference/functions/network_site_url/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/network_site_url/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/network_site_url/?output_format=md#changelog)󠁿

| Version | Description | 
| [3.0.0](https://developer.wordpress.org/reference/since/3.0.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/network_site_url/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 4 content](https://developer.wordpress.org/reference/functions/network_site_url/?output_format=md#comment-content-5373)
 2.    [pcarvalho](https://profiles.wordpress.org/pcarvalho/)  [  5 years ago  ](https://developer.wordpress.org/reference/functions/network_site_url/#comment-5373)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fnetwork_site_url%2F%23comment-5373)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fnetwork_site_url%2F%23comment-5373)
 4.  if wp is in a subdir /wp/site1/, ‘path’ contains ‘wp/’, so beware.
 5.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fnetwork_site_url%2F%3Freplytocom%3D5373%23feedback-editor-5373)
 6.   [Skip to note 5 content](https://developer.wordpress.org/reference/functions/network_site_url/?output_format=md#comment-content-1052)
 7.    [Codex](https://profiles.wordpress.org/codex/)  [  10 years ago  ](https://developer.wordpress.org/reference/functions/network_site_url/#comment-1052)
 8.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fnetwork_site_url%2F%23comment-1052)
     Vote results for this note: -1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fnetwork_site_url%2F%23comment-1052)
 9.  **With https specification**
      Output: [https://www.example.com/contact-us/](https://www.example.com/contact-us/)
 10.     ```php
         // Get a secure URL for a specific page within the current site
         $url = network_site_url('/contact-us/', 'https');
         echo $url;
         ```
     
 11.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fnetwork_site_url%2F%3Freplytocom%3D1052%23feedback-editor-1052)
 12.  [Skip to note 6 content](https://developer.wordpress.org/reference/functions/network_site_url/?output_format=md#comment-content-1051)
 13.   [Codex](https://profiles.wordpress.org/codex/)  [  10 years ago  ](https://developer.wordpress.org/reference/functions/network_site_url/#comment-1051)
 14. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fnetwork_site_url%2F%23comment-1051)
     Vote results for this note: -3[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fnetwork_site_url%2F%23comment-1051)
 15. **Basic Example**
      Output: [http://www.example.com/wordpress/](http://www.example.com/wordpress/)
 16.     ```php
         // Get the current site's URL
         $url = network_site_url();
         echo $url;
         ```
     
 17.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fnetwork_site_url%2F%3Freplytocom%3D1051%23feedback-editor-1051)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fnetwork_site_url%2F)
before being able to contribute a note or feedback.