Antony Krinis
Antony Krinis

Reputation: 45

How to show different content in multisite with the network_site_url() function?

I am stuck with the function network_site_url() and the if statement. I want to show different content via my different Multisite.

Here is the code:

$url= network_site_url();

if ($url=='string-url'){

     the_content( __( 'example1 <span class="meta-nav">&rarr;</span>', 'esquire' ) ); }

else{ 

the_content( __( 'example2 <span class="meta-nav">&rarr;</span>', 'esquire' ) );  } 

In fact the string value of the $url variable must be either http://www.example.com or http://www.example.com/it.

How to do it?

Upvotes: 1

Views: 396

Answers (2)

Antony Krinis
Antony Krinis

Reputation: 45

Thank you for your help. I've tried and it works pretty well.

I found also another way.

 global $current_blog;
 if($current_blog-> blog_id == 2){
 //content }
 else{
 //content}

Upvotes: 0

brasofilo
brasofilo

Reputation: 26065

You are looking for get_current_blog_id(), network_site_url() is to simply "Retrieve the site url for the current network.".

switch( get_current_blog_id() )
{
    case 1:
        echo 'main site';
    break;
    case 43:
        echo 'site #43');
    break;
}

Upvotes: 1

Related Questions