WordPress get_site_url() Function

Beginner
6 min read
Updated: Nov 2026
3 examples
Returns a URL

Definition

In WordPress, get_site_url() returns the site URL. This is the address where the WordPress core files live, the place that holds wp-admin and wp-login.php.

Most sites use the same address for the front page and for WordPress. If you install WordPress in a subfolder, such as /wp, they can differ. The first argument lets you pick a site on a multisite network.

Syntax

Return the URL and print it with esc_url().

WordPress
<?php echo esc_url( get_site_url() ); ?>
CallWhat it does
get_site_url()The site URL of the current site.
get_site_url( null, 'wp-login.php' )The login page URL.
get_site_url( 2 )The site URL of site 2 on a multisite.

It returns a string. For the address of the front page, use get_home_url().

Full declaration
WordPress
get_site_url( int|null $blog_id = null, string $path = '', string|null $scheme = null ): string

Parameters

ParameterDescription
$blog_idint|null. Site ID on a multisite. Default is null, the current site.
$pathstring. A path to add after the site URL, such as wp-login.php.
$schemestring|null. http, https, login, login_post, admin, or relative. Default is null.

Return Value

Return ValueDescription
stringThe site URL, with the path added when you pass one.

WordPress Examples

Three short examples. Each one shows the code and what it prints or does.

Example 1 — Print the site URL

The simplest call. Imagine WordPress is installed in a /wp folder.

WordPress
<?php
echo esc_url( get_site_url() );

How It Works

  1. get_site_url() returns where WordPress is installed.
  2. In this example the install folder is /wp.
  3. On a normal site you would see https://example.com.

Example 2 — Link to the login page

Add a path to point to a WordPress file.

WordPress
<?php
echo esc_url( get_site_url( null, 'wp-login.php' ) );

How It Works

  1. null means the current site.
  2. wp-login.php is added to the site URL.
  3. This is the real login page, even in a subfolder.

Example 3 — Compare site URL and home URL

See the difference side by side.

WordPress
<?php
echo 'Home: ' . esc_url( get_home_url() ) . "\n";
echo 'Site: ' . esc_url( get_site_url() );

How It Works

  1. get_home_url() is the address visitors use.
  2. get_site_url() is where WordPress is installed.
  3. They match on most sites, but they do not have to.

Frequently Asked Questions

It returns the address where WordPress is installed. That is the base for wp-admin and wp-login.php.
Home URL is the address of your front page. Site URL is where WordPress files live. They are the same on most sites.
site_url() is the short version for the current site. get_site_url() lets you choose a site on multisite.
No. It returns it. Use echo with esc_url().
In Settings, then General, under WordPress Address (URL).

Next: get_the_privacy_policy_link()

Return the Privacy Policy link as HTML, or an empty string if none is set.

get_the_privacy_policy_link() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful