home_url() WordPress Function

The home_url() function is a Wordpress function that returns the home page URL for the current site.

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

Retrieves the URL for the current site where the front end is accessible.


Description

Returns the ‘home’ option with the appropriate protocol. The protocol will be ‘https’ if is_ssl() evaluates to true; otherwise, it will be the same as the ‘home’ option. If $scheme is ‘http’ or ‘https’, is_ssl() is overridden.


Top ↑

Parameters

$path

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

Default value: ''

$scheme

(string|null)(Optional) Scheme to give the home URL context. Accepts 'http', 'https', 'relative', 'rest', or null.

Default value: null


Top ↑

Return

(string) Home URL link with optional path appended.


Top ↑

Source

File: wp-includes/link-template.php

function home_url( $path = '', $scheme = null ) {
	return get_home_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