如何检测我在哪个网站?

时间:2014-06-10 13:44:31

标签: wordpress-theming wordpress

我正在使用WordPress" multisite"对于我网站上的不同语言,我想知道我怎么知道我在哪个网站上。我可以轻松查看它是哪个页面,但对于网站来说,这有点棘手。我已经为Eng建立了网站,并为Fr建立了网站,还有更多。

到目前为止,我已尝试使用以下网址检查网址:

stripos($_SERVER['REQUEST_URI'],'/Eng/') 

有不同的方法吗?

1 个答案:

答案 0 :(得分:1)

使用get_current_blog_id()http://codex.wordpress.org/Function_Reference/get_current_blog_id

E.g。

$blog_id = get_current_blog_id();

我会做类似的事情:

if ( 1 === $blog_id ) {
    echo 'This is the Eng site.';
}

如果有多种语言选项可供测试,那么使用开关会更好:

switch ( $blog_id ) {
    case 1:
        echo 'This is the Eng site.';
        break;
}