WordPress

home_url()

Syntax#

  • home_url( $path, $scheme );

Parameters#

Parameter Details
$path (String,Optional) To adding more segment after the home url.
$scheme (String,Optional) Scheme to give the home url context. Accepts ‘http’, ‘https’, ‘relative’, ‘rest’, or null.
## Getting the Home URL
home_url() is used for retrieving the current site home url.
<?php echo esc_url( home_url( '/' ) ) ); ?>

Output

https://www.example.com

Site url

Returns the ‘site_url’ option with the appropriate protocol (https://)

<?php echo site_url(); ?>

Output

https://www.example.com

This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow