Skip to content

Instantly share code, notes, and snippets.

@daltonnyx
Created July 2, 2017 19:22
Show Gist options
  • Save daltonnyx/30230662ae34dbf6c0ac0780057d28eb to your computer and use it in GitHub Desktop.
Save daltonnyx/30230662ae34dbf6c0ac0780057d28eb to your computer and use it in GitHub Desktop.
<?php
add_filter('template', 'change_theme');
add_filter('option_template', 'change_theme');
add_filter('option_stylesheet', 'change_theme');
function change_theme()
{
require_once("/path/to/Mobile_Detect.php");
$detect = new Mobile_Detect;
$deviceType = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') :
'computer');
switch($deviceType):
case 'computer': $theme = 'default_theme_name';
break;
case 'tablet': $theme = 'tablet_theme_name';
break;
case 'phone': $theme = 'phone_theme_name';
break;
default: $theme = 'default_theme_name';
break;
endswitch;
return $theme;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment