Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the PHP function used to get the home page and site links in WordPress

Shulou Source: shulou.com Published: 2022-06-03 19:36:36 11月12日 Update

This article is about what the PHP function used to get the home page and site links in WordPress is. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Home_url () (get the home page link)

The ome_url () function is used to get the link to the home page of WordPress.

Usage

Home_url ($path, $scheme)

Parameters.

$path

(string) (optional) the content appended after the home link is a relative link.

Default value: None

$scheme

(string) (optional) Link protocol, which only supports "http", "https" and "relative".

Default value: null

Return value

(string) returns the home page URL plus the $path parameter.

Examples

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

Other

This function is located at: wp-includes/link-template.php

Site_url () (get site links)

The site_url () function is used to get a link to the site of WordPress.

Usage

Site_url ($path, $scheme)

Parameters.

$path

(string) (optional) what is appended after the link.

Default value: None

$scheme

(string) (optional) Link protocol, only "http", "https", "login", "admin" and "relative" are allowed.

Default value: null

Return value

(string) return the site link with the $path parameter.

Examples

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/ thank you for reading! About "what is the PHP function used to get the home page and site links in WordPress?" this article ends here. I hope the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, you can share it out for more people to see it!

Tags: Links home pages characters strings output functions sites content parameters examples more articles good practical articles see knowledge references help support Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Shulou Information Microsoft Linux vpn