首页>文档>Wordpress开发文档>Wordpress 函数>get_site_url() 获取网站url地址

get_site_url() 获取网站url地址

函数描述

get_site_url() 模板标签获取指定站点的站点url,根据相应的协议返回 ‘siteurl’ 选项值,如果is_ssl()为true,返回 ‘https’,否则为 ‘http’ ,如果 $scheme 为 ‘http’ 或 ‘https’, is_ssl() 将被覆盖。

使用方法

<?php get_site_url( $blog_id, $path, $scheme ); ?>

默认使用方法

<?php get_site_url(); ?> 

函数参数

参数数据类型是否必需描述默认值
$blog_id整数博客 ID当前博客ID
$path字符串相对于站点URL的地址
$scheme字符串指定给站点url的上下文方案,当前可用的有: ‘http’, ‘https’, ‘login’, ‘login_post’, ‘admin’ 或 ‘relative’.null

返回值

(string) 添加有可选后缀路径的站点url

Filter

apply_filters( 'site_url', $url, $path, $orig_scheme, $blog_id );

使用示例

<?php echo get_site_url(); ?>

返回完整的URL

http://www.example.com
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索