当前浏览:首页 / WordPress函数 / is_main_site()

is_main_site( int $site_id = null, int $network_id = null )

站点是否为当前网络的主站点

is 条件判断more...

main

sitemore...


描述

更多类似的主题函数信息,请查看主题开发手册中的条件标签文章。


参数

$site_id

(int) (可选) 要测试的站点ID,默认为当前站点。

默认值: null

$network_id

(int) (可选) 要检查的网络ID,默认为当前网络。

默认值: null


返回

(bool) 如果$site_id是网络的主站点,或者如果没有运行多站点,则为true


说明

替换函数is_main_blog(),自3.0.0以来已弃用。(wp-includes/ms-deprecated.php)



源码

查看源码 官方文档


更新日志

版本描述
4.9.0添加了$network_id参数
3.0.0开始引入

使用示例

  • 示例1

    示例

    if ( is_main_site( $blog_id ) ) {
      // display something special for the main site.
    }