home_url

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

Description

(string) home_url( (string) $path = '', (null) $scheme = null ); 

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.

Returns (string)

Home URL link with optional path appended.

Parameters (2)

0. $path — Optional. (string) => ''
Path relative to the home URL. Default empty.
1. $scheme — Optional. (null) => null
Scheme to give the home URL context. Accepts http,, https, relative, rest, or null. Default null.

Usage

  1. if ( !function_exists( 'home_url' ) ) { 
  2. require_once ABSPATH . WPINC . '/link-template.php'; 
  3.  
  4. // Optional. Path relative to the home URL. Default empty. 
  5. $path = ''; 
  6.  
  7. // Optional. Scheme to give the home URL context. Accepts 
  8. // 'http', 'https', 'relative', 'rest', or null. Default null. 
  9. $scheme = null; 
  10.  
  11. // NOTICE! Understand what this does before running. 
  12. $result = home_url($path, $scheme); 
  13.  

Defined (2)

The function is defined in the following location(s).

/wp-includes/link-template.php  
  1. function home_url( $path = '', $scheme = null ) { 
  2. return get_home_url( null, $path, $scheme ); 
/wp-admin/includes/noop.php  
  1. function home_url() {}