Function: get_site_url

get_site_url( integer $blog_id, string $path, string $scheme )

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

Returns the 'site_url' option with the appropriate protocol, 'https' if is_ssl() and 'http' otherwise. If $scheme is 'http' or 'https', is_ssl() is overridden.

Parameters

Name Type(s) Default Value Description
$blog_id integer null

Optional. Site ID. Default null (current site).

$path string ''

Optional. Path relative to the site URL. Default empty.

$scheme string null

Optional. Scheme to give the site URL context. Accepts 'http', 'https', 'login', 'login_post', 'admin', or 'relative'. Default null.

Returns

string

Site URL link with optional path appended.

WordPress Developer Newsletter

Stay on top of the latest WordPress API changes, developer tool updates, security alerts and more.