How to detect mobile visitors on your WordPress blog

December 9, 2009 at 9:11 am

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

To achieve this recipe, you first have to get the code from 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.

$mobile = mobile_device_detect();

if ($mobile==true) {
  header( 'Location:' ) ;

Thanks to Jeff Starr for this very cool idea!

By the way, did you checked out the Headway theme for WordPress? It is pretty amazing. I’ll publish a review about it soon at Cats Who Blog.