來源于:
https://www.jb51.net/article/76570.htm
home_url()(獲取首頁鏈接)
ome_url() 函數(shù)用來獲取 WordPress 的首頁鏈接。
用法
home_url( $path, $scheme );
參數(shù)
$path
(字符串)(可選)在首頁鏈接后邊追加的內(nèi)容,是相對鏈接。
默認(rèn)值:None
$scheme
(字符串)(可選)鏈接協(xié)議,只支持 “http”,“https” 和 “relative”。
默認(rèn)值:null
返回值
(字符串)返回首頁 URL 加上 $path 參數(shù)。
例子
echo home_url();//輸出:http://www.example.com
echo home_url( '/' );//輸出:http://www.example.com/
echo home_url( '/', 'https' );//輸出:https://www.example.com/
echo home_url( 'example', 'relative' );//輸出:/example
其它
此函數(shù)位于:wp-includes/link-template.php
site_url()(獲取站點鏈接)
site_url() 函數(shù)用來獲取 WordPress 的站點鏈接。
用法
site_url( $path, $scheme );
參數(shù)
$path
(字符串)(可選)在鏈接后追加的內(nèi)容。
默認(rèn)值:None
$scheme
(字符串)(可選)鏈接協(xié)議,只允許 “http”、“https”、“l(fā)ogin”、“admin” 和 “relative”。
默認(rèn)值:null
返回值
(字符串)返回站點鏈接加上 $path 參數(shù)。
例子
echo site_url();//輸出:http://www.example.com 或者 http://www.example.com/wordpress
echo site_url( '/secrets/', 'https' );//輸出:https://www.example.com/secrets/ 或者 https://www.example.com/wordpress/secrets/
其它
此函數(shù)位于:wp-includes/link-template.php