2
votes

So I have a wordpress Multisite with about 15 different sites.

Just an example:

country.com (main site)

  • usa.country.com
  • china.country.com
  • france.country.com

Now lets say in china.country I wanted an h1 tag that says "THIS IS CHINA" on the header BUT not on any other multisite not even the main one. Is there a conditional for that? I checked the wordpress codex but no luck there, only thing I could find was is_main_site() which did not help.

So basically I am looking for a conditional that allows me to select different multisite so I can have different content on them.

Also I am not too familiar with wordpress multisite since this is my first one but I do know that I can also instead of using the multisite feature create a sub directory and install wordpress in that sub directory and it would accomplish the same thing but each multisite files would be separate which sounds good rite about now but im not sure. Any info on how I can have distinct content for each multi site would be appreciated or if I should not even be using multi site and do it manually by created a sub directory and installing wordpress on there.

Thank you.

I forgot to mention that their all using the same theme. So they all share the same index.php(home) file which means I would need a conditional to change the look of the other multi sites.

1
Each site in a multi-site installation can have utterly different everything. You can choose a different WordPress theme for each site and put anything you like in there. In some ways, the problem is normally the opposite, of having common content/look across all the sites...Matt Gibson
I forgot to mention that their all using the same theme. So they all share the same index.php(home) file which means I would need a conditional to change the look of the other multi sites.Lucas Santos
Ah, okay. In that case, you're probably looking for get_current_blog_id or the potentially more useful get_blog_details, which will return you an object of information about the current blog, including the domain, for example. (In multi-site, each of your "sites" is actually a "blog"; the "site" is the overall network.)Matt Gibson

1 Answers

4
votes

Behind the scenes in WordPress multi-site, each "site" is actually called a "blog" (the "site" is the overall network.) Each of your different blogs will have a different ID. You can fetch the ID using get_current_blog_id.

To make the code easier to read, though, I'd probably use get_blog_details, which returns an array of information about a blog, including the domain:

$blog_details = get_blog_details(get_current_blog_id());

echo "This is the {$blog_details->blogname} site!";

if ($blog_details->domain == 'usa.country.com') {
    // I'm in the USA!
}