Mobile web surfing is continuing to evolve on a larger scale. This is why detecting those users who are visiting your WordPress blog through a mobile device and redirecting them to a mobile version of your site is important. In order to achieve this, you first have to get the code from detectmobilebrowsers.mobi and upload it to your theme directory.

Then, all you simply have to do is open your header.php file and place the following at the top of the file. Remember to edit line 4 to where you’d like to redirect mobile users.

The Source:

include('mobile_device_detect.php');
$mobile = mobile_device_detect();
if ($mobile){
    header('Location: http://your-website.com/?theme=Your_Mobile_Theme');
}