site_url

Retrieves the URL for the current site where WordPress application files (e.

Description

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

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.

Returns (string)

Site URL link with optional path appended.

Parameters (2)

0. $path — Optional. (string) => ''
Path relative to the site URL. Default empty.
1. $scheme — Optional. (null) => null
Scheme to give the site URL context. See set_url_scheme().

Usage

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

Defined (2)

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

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