This article describes the PHP functions used in WordPress to obtain the home page and site links. For more information, see home_url () and site_url ().
Home_url () (get the homepage link)
The ome_url () function is used to obtain the WordPress homepage link.
Usage
home_url( $path, $scheme );
Parameters
$ Path
(String) (optional) The content appended to the homepage link is a relative link.
Default value: None
$ Scheme
(String) (optional) connection protocol. only "http", "https", and "relative" are supported ".
Default value: null
Return value
(String) returns the home page URL with the $ path parameter.
Example
Echo home_url (); // output: http://www.example.comecho home_url ('/'); // output: http://www.example.com/echo home_url ('/', 'https'); // output: https://www.example.com/echo home_url ('example ', 'relative'); // output:/example
Others
This function is located in: wp-des/link-template.php
Site_url () (get site link)
The site_url () function is used to obtain the WordPress site link.
Usage
site_url( $path, $scheme );
Parameters
$ Path
(String) (optional) content appended after the link.
Default value: None
$ Scheme
(String) (optional) connection protocol. only "http", "https", "login", "admin", and "relative" are allowed ".
Default value: null
Return value
(String) returns the site link with the $ path parameter.
Example
Echo site_url (); // output: http://www.example.com or http://www.example.com/wordpressecho site_url ('/secrets/', 'https'); // output: https://www.example.com/secrets/ or https://www.example.com/wordpress/secrets/
Others
This function is located in: wp-des/link-template.php