site_url() WordPress Function

The site_url() function is used to retrieve the home URL for the current site. This function is useful for creating links to other pages on the site.

site_url( string $path = '', string|null $scheme = null ) #

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


Description

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.


Top ↑

Parameters

$path

(string)(Optional) Path relative to the site URL.

Default value: ''

$scheme

(string|null)(Optional) Scheme to give the site URL context. See set_url_scheme().

Default value: null


Top ↑

Return

(string) Site URL link with optional path appended.


Top ↑

Source

File: wp-includes/link-template.php

function site_url( $path = '', $scheme = null ) {
	return get_site_url( null, $path, $scheme );
}


Top ↑

Changelog

Changelog
VersionDescription
3.0.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More