I have a single installation of WordPress that is powering two domain names. To put it very simply, Site A has four static pages, and Site B has four static pages, but they both share a common blog-posts page.
Site A should have a navbar at the top that points to the other Site A pages and Site B should have a navbar that points to the other Site B pages.
Since they (necessarily) share a common WordPress theme, in the header.php
file I would like to put a PHP if
statement for a block of code that is the Site A nav and another for the Site B nav. But I’m not sure what condition to actually check for. Is there some way I can cause some pages to identify themselves to PHP as belonging to Site A, and others to Site B?
You could set variables in both sites before the header call, then use an if statement to show the right navigation.
Site A
header.php
However, if your two sites have different domain names, you could look at the
$_SERVER
global and key off of that directly in yourheader.php
instead.If this two websites have different domain name you can validate by doing: