Skip to content


How to detect mobile visitors on your WordPress blog December 15, 2009

Posted in How To. 141 views

No comments

As mobile devices, as such as Blackberries or iPhones, are becoming more and more popular, bloggers may want to detect those visitors and redirect them to a mobile version of their blog. Here is a tutorial to detect mobile visitors.

To achieve this, you first have to get the code from detectmobilebrowsers.mobi and upload it to your theme directory.

Once done, simply open your header.php file and place the following at the top of the file. Don’t forget to edit line 5 according to the page where you’d like to redirect mobile users.

include('mobile_device_detect.php');

$mobile = mobile_device_detect(); 

if ($mobile==true) { 

header( 'Location: http://your-website.com/?theme=Your_Mobile_Theme' ) ;

}

If you enjoyed this post, please share!


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.

Powered by WP Hashcash