Codex

Function Reference/home url

Contents

Description

The home_url template tag retrieves the home url for the current site with the appropriate protocol, 'https' if is_ssl() and 'http' otherwise. If scheme is 'http' or 'https', is_ssl() is overridden.

In case of WordPress Network setup, use network_home_url() instead.

Usage

<?php home_url$path$scheme ); ?>

Default Usage

<?php echo home_url(); ?>

Parameters

$path
(string) (optional) Path relative to the home url.
Default: None
$scheme
(string) (optional) Scheme to give the home url context. Currently 'http','https'.
Default: null

Return

(string) 
Home url link with optional path appended.

Example

$url = home_url();
echo $url;

Output: http://www.example.com

(Note the lack of a trailing slash)

$url = home_url('/');
echo $url;

Output: http://www.example.com/

Notes

Changelog

Source Code

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

Related

home_url() Home URL http://www.example.com
site_url() Site directory URL http://www.example.com OR http://www.example.com/wordpress
admin_url() Admin directory URL http://www.example.com/wp-admin
includes_url() Includes directory URL http://www.example.com/wp-includes
content_url() Content directory URL http://www.example.com/wp-content
plugins_url() Plugins directory URL http://www.example.com/wp-content/plugins
wp_upload_dir() Upload directory URL (returned array) http://www.example.com/wp-content/uploads
See also index of Function Reference and index of Template Tags.
This page is marked as incomplete. You can help Codex by expanding it.