简介WordPress中用于获取首页和站点链接的PHP函数
home_url()(获取首页链接)
ome_url()函数用来获取WordPress的首页链接。
用法
home_url($path,$scheme);
参数
$path
(字符串)(可选)在首页链接后边追加的内容,是相对链接。
默认值:None
$scheme
(字符串)(可选)链接协议,只支持“http”,“https”和“relative”。
默认值:null
返回值
(字符串)返回首页URL加上$path参数。
例子
echohome_url();//输出:http://www.example.com echohome_url('/');//输出:http://www.example.com/ echohome_url('/','https');//输出:https://www.example.com/ echohome_url('example','relative');//输出:/example
其它
此函数位于:wp-includes/link-template.php
site_url()(获取站点链接)
site_url()函数用来获取WordPress的站点链接。
用法
site_url($path,$scheme);
参数
$path
(字符串)(可选)在链接后追加的内容。
默认值:None
$scheme
(字符串)(可选)链接协议,只允许“http”、“https”、“login”、“admin”和“relative”。
默认值:null
返回值
(字符串)返回站点链接加上$path参数。
例子
echosite_url();//输出:http://www.example.com或者http://www.example.com/wordpress echosite_url('/secrets/','https');//输出:https://www.example.com/secrets/或者https://www.example.com/wordpress/secrets/
其它
此函数位于:wp-includes/link-template.php