You have not closed the else statement correctly.. see below.
<?php if ( is_mobile() ) { ?>
Mobile Content
<? } else { ?>
Wired/Desktop Content
} ?>
Thanks – but that’s not the problem; only a typo in my example I’m afraid
What device are you testing on? You may need to check the device you are using is correctly identified as mobile here: http://demo.mobiledetect.net/
If it is correctly detected you may also need to update the mobile detect library within the plugin (something I have not done for some time).
This is a correct code and i have tested and works fine..
<?php if ( is_mobile() ) { ?>
mobile
<?php } else { ?>
no
<?php } ?>
It is an iPhone 6 running iOS8. I’ve setup the conditional as it appears above, but the browser on both my desktop computer AND mobile device seems just to ignore the conditional and display all of the content.
mobble relies on a PHP library called mobile detect (http://mobiledetect.net/) and it may need updating to reflect new devices.
Can you try downloading the latest version of mobile detect and replacing it with the one in mobble (mobile-detect.php) and post back if it works for you.
I’m actually having the same issue with conditional statements.
It’s weird.
<?php if ( is_mobile() ) { ?>
mobile
<?php } else { ?>
no
<?php } ?>
If I set the code up like that, it shows on mobile, desktop, everywhere, the content in the else statement but won’t recognize the mobile statement.
Any ideas?
This is cross browser, cross platform. It’s the weirdest damned thing.
It sounds like your site is most likely being cached. So your first visit (on desktop) is being remembered for subsequent visits on mobile and by other visitors. Some cache plugins can be configured to work but it really depends on how your site and server are setup.