home_url () retrieves the current site can be accessed URL ( recommended the <php bloginfo ( 'url') ;??> with <php home_url ();?? > instead), use the appropriate protocol return 'home' option. If is_ssl () judgment result is true, the protocol 'https'; otherwise, it will be the same as the "home" option. If the $ scheme is 'http' or 'https', then rewrite is_ssl ().
HOME_URL () method using
<?php home_url($path = '', $scheme = ''); ?>
Parameter Description
$ Path. (String type), optionally, the relative path of the site url, defaults to '' null
$ scheme. ( String type | null), optional, to provide relevant solutions url of the website
Examples of use
<?php $url = home_url(); echo $url; ?>
The results obtained are http://www.example.com
<?php $url = home_url( '/' ); echo $url; ?>
Get results is http://www.example.com/, note that there is a final / slash
<?php $url = home_url( $path = '/', $scheme = https ); echo $url; ?>
The results obtained are https://www.example.com/, note the https protocol
<?php $url = home_url( $path = 'example', $scheme = relative ); echo $url; ?>
Results obtained are / example, a relative address
Through the above explanation, we detail () have a deeper understanding of the home_url, this is ytkah want to see
References https://developer.wordpress.org/reference/functions/home_url/