user3042036
user3042036

Reputation: 325

How to detect on which site am I?

I am using WordPress "multisite" for different languages on my site, and I want to know how can I know on which site am I. I can easily check which page is it, but for the site, It is little bit tricky. I have made site for Eng, and site for Fr, and couple more.

So far I have tried to check URL with :

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

Is there different way to do this?

Upvotes: 0

Views: 53

Answers (1)

Nathan Dawson
Nathan Dawson

Reputation: 19318

Use get_current_blog_id(): http://codex.wordpress.org/Function_Reference/get_current_blog_id

E.g.

$blog_id = get_current_blog_id();

I'd do something like:

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

If there are multiple language options to test you'd be better with a switch:

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

Upvotes: 1

Related Questions