More wp247 Body Classes

Well, the wp247 Body Classes WordPress plugin has been out for a couple of weeks now and a few people have started using it. One person asked if it could indicate whether or not a mobile user is on a tablet. The simple answer was No. But not any longer.

Unfortunately, there is no easy way to determine the mobile device type. But, after a bit of searching, I came across a great little script from mobiledetect.net called, you guessed it, MobileDetect. This script does a lot of interrogation of the HTTP_USER_AGENT string to determine all types of mobile attributes – including if it is a tablet.

wp247 Body Classes now supports adding classes to your <body> tag based on the MobileDetect script. So, now you can go really crazy, like tailor your web design based on .is-tablet vs. .is-phone, or .is-ipad vs. .is-kindle, or .is-ios vs. .is-androidos, or .is-chromebrowser, or (well, you get the idea).

Hope this comes in handy for someone. And, if you have any other ideas of Body Classes that you would like to see added to wp247 Body Classes, then please drop us a line.

1 thought on “More wp247 Body Classes”

  1. Unfortunately, the answer is highly dependent on your website and the theme you are using. In general, use your browser’s ability to view the source of the page or inspect elements to see the html structure. Identify the id of the section to be hidden and then do something like:

    body.is-mobile #id-of-mobile-section-to-hide {display: none;}
    body.is-not-mobile #id-of-non-mobile-section-to-hide {display: none;}

    Hope this helps.

    Reply

Leave a Comment