WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a homesite and a second site. They are displayed to normal browsers.

But I would like to show IOS and mobile devices the second site as homesite and hide the normal homesite.

How can I do this?


share|improve this question

If the url's for both site is different, You can simply check if site is being viewed from mobile or not and than you can redirect to your second site if it is mobile...

Here is one of code who detects whether it is mobile or not...


You can use such code detect mobile browser agent and put it on first site and if mobile is detected redirect them to second site..

share|improve this answer

You can use a plugin like W3 Total Cache which has User Agent detection and can serve a different theme or redirect to a mobile site based on what browser a visitor is using.

WordPress has some more basic User Agent detection built in. You can target the iPhone with the is_iphone function. So for example you could add something like this to your themes header.php:

<?php global $is_iphone; if($is_iphone) { ?>
     <meta http-equiv="refresh" content="0; url=http://MobileSite.com/">
<?php } ?>

Here's a list of all the browser detection functions from the WordPress Codex.

share|improve this answer
There aren't conditional functions for this. These are global variables. Instead of is_iphone() you have to use global $is_iphone; if($is_iphone) – rofflox Sep 25 '11 at 17:03
Ahh,thanks. I hadn't tested it, I've updated my answer. – Jono Warren Sep 25 '11 at 20:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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