0
votes

I have 2 domains sharing the same Wordpress theme. I don't want to manage 2 separate themes, but there are a few small differences in the sites. I want to do something similar to the:

<?php if ( is_page( 'Contact' )) { ?>
  <!-- Contact content -->
<?php } else { ?>
  <!-- Other content -->
<?php } ?>

But instead of looking for a page, it is looking for a different full URL: Such as http://example.com versus http://example.net.

1
so why not something like if (is .net site) && (is_page(...))?Marc B

1 Answers

0
votes

You can try this:

<?php if ( $_SERVER['HTTP_HOST'] == 'example.net' ) : ?>
    <div> Example.net</div>
<?php else : ?>
    <div> Example.com</div>
<?php endif; ?>

Or if you want to use regex:

<?php if ( preg_match('/\.example.net/', $_SERVER['HTTP_HOST']) ) : ?>
    <div> Example.net</div>
<?php else : ?>
    <div> Example.com</div>
<?php endif; ?>