WordPress.org

Ready to get started?Download WordPress

Codex

Function Reference/get site url

Contents

Description

The get_site_url() template tag retrieves the site url for a given site. Returns the 'siteurl' option with the appropriate protocol, 'https' if is_ssl() and 'http' otherwise. If $scheme is 'http' or 'https', is_ssl() is overridden.

Usage

<?php get_site_url$blog_id$path$scheme ); ?>

Default Usage

<?php get_site_url(); ?>

Parameters

$blog_id
(integer) (optional) Blog ID.
Default: current blog
$path
(string) (optional) Path relative to the site url.
Default: None
$scheme
(string) (optional) Scheme to give the site url context. Currently 'http', 'https', 'login', 'login_post', 'admin' or 'relative'.
Default: null

Return

(string) 
Site url link with optional path appended.

Filter

apply_filters( 'site_url', $url, $path, $orig_scheme, $blog_id );

Examples

<?php echo get_site_url(); ?>

Results in the full site URL being displayed

http://www.example.com

Changelog

Source Code

get_site_url() is located in wp-includes/link-template.php.

Related

See also index of Function Reference and index of Template Tags.