There is currently no functionality built in to directly change theme depending on mobile device – rather it changes to a mobile theme, which you can then perform conditional statements within.
For example, you can include a different stylesheet if you are using an iPhone:
global $mobile_smart;
if ($mobile_smart && $mobile_smart->getCurrentDevice() == MOBILE_DEVICE_IPHONE) {
?>
<link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/css/iphone.css"/>
<?php
}
Or you can include different loop files, e.g.
global $mobile_smart;
if ($mobile_smart && $mobile_smart->getCurrentDevice() == MOBILE_DEVICE_IPHONE) {
get_template_part('loop', 'iphone'); // looks for loop-iphone.php in your theme folder
}
else {
get_template_part('loop'); // looks for loop.php in your theme folder
}
Does this help you?
Best…Dan
Hey Dan, thanks for the great plugin. I’m looking for an avenue of disabling the theme swap for Tablet, and specifically iPad platforms. Is there any quick hackish way to get around this? Thanks.
Hi Dan,
I’m currently writing an admin screen for excluding devices, however, in the meantime:
in the DetectIsMobile() function, on line 663, modify it from:
return ( $this->DetectMobileQuick() || $this->DetectIpad() );
to
return ( $this->DetectMobileQuick() /*|| $this->DetectIpad()*/ );
Hope this helps,
Dan
Thanks Dan, works brilliantly. Looking forward to the update as well, thank you for all the good work.
Thread Starter
genim
(@genim)
Thanks Dan….
somehow i got it using a your conditions with
a few twists….
Glad it works danpaulson and genim.
Genim – any chance you could post here what those twists were, in case it can help others in the same situation?
Cheers…Dan
Thought I’d throw my 2c in, as I was just looking into this same issue for someone. I used this in my child theme’s functions file to add the desktop cookie for tablets.
function desktop_tablet() {
global $mobile_smart;
if ($mobile_smart->DetectTierTablet() && !isset($_COOKIE[MOBILESMART_SWITCHER_COOKIE]))
setcookie(MOBILESMART_SWITCHER_COOKIE,'desktop');
$current_page = $_SERVER['PHP_SELF'];
header("Location: $current_page");
}
add_action('template_redirect','desktop_tablet');