0

I'm working on a site where each agent has their own subdomain. Each subdomain directs to the content on the main page, there is no difference in content. The only difference requested is a banner that changes based on the subdomain used. For example: bob.example.com Would direct to example.com with a banner at the top that says "Welcome to Agent Bob's Portal!" I'm not very experienced with WordPress, but what I was aiming for was something like:

<?php $url = $_SERVER["REQUEST_URI"];
 if (strpos($url, "bob."))  {
           print "Welcome to Agent Bob's Portal!";
        }
} ?>

The problem is that I'm not quite sure where to put it. I've tried putting it in the page.php file, surrounded by a div that encapsulates the area I want the text in, but that doesn't seem to work. Is there something else you would recommend trying?

0

You can put you code in functions.php where you define the string, for example:

<?php   
function get_banner_text() {
  $url = $_SERVER["REQUEST_URI"];
  if (strpos($url, "bob."))  {
    $banner_text = "Welcome to Agent Bob's Portal!";
  } else {
    $banner_text = "Default text here";
  }
  return $banner_text;
}
?>

Afterwards for example in header.php of your theme you could have like:

<div class="banner"><?php echo get_banner_text(); ?></div>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.