Is it possible to use PHP if-else, specifically mobiledetect.php?
-
Hello!
I’m having a bit of a dilemma between using mobiledetect (https://mobiledetect.net/)
and W3 Total Cache.If I’ve understood correctly, If I write any kind of if-else php in my WordPress site, Caching plugins create static HTML pages from what comes out of those php-files and serve that to the next visitors.
This becomes a problem, if I have code like:
if ( $detect->isMobile() ) {
// do someting for mobile devices only, like add class .mobile to the body or restrict the number of posts in a loop etc
}I probably can use some of W3 Total Cache features but not all of them?
I would really appreciate any thoughs here since I’d hate to not be able to use W3 Total Cache, but I have problems living without mobiledetect too since pretty much all similar solutions (mobile detect js libraries, modernizr.js etc.) just won’t cut it.
Most of my worries would be gone if I could just get a class .computer, .tablet, .mobile to the body. Of course javascript would be the obvious solution but so far nothing comes close to this one in reliability and ease of use.
Thank you very much in advance!
- The topic ‘Is it possible to use PHP if-else, specifically mobiledetect.php?’ is closed to new replies.