How does wordpress determine whether a Mobile phone, tablet, or PC is displayed and the corresponding content is displayed-mobile Detect, wordpress-Mobile
How does wordpress determine whether it is a mobile phone, tablet, or PC Access, and display specific content? Mobile Detect, a lightweight PHP class library, can implement this function well. In addition, Mobile Detect also has plug-ins available under wordpress-WP Mobile Detect,Wordpress uses this plug-in to easily display specific content based on different terminal devices, such as responsive wordpress Themes.
Install the WP Mobile Detect plug-in
Log on to the wordpress management background, select "Install plug-in" on the plug-in management page, and enter the keyword "WP Mobile Detect" in the search box ", then, on the search results page, select "WP Mobile Detect" and install it.
Install the WP Mobile Detect plug-in
Search for WP Mobile Detect plug-in
How to Use WP Mobile Detect
Use the [keyword] In the wordpress Article editor for tagging, for example
How to use Mobile Detect
Or use a function in php code to determine
Wpmd_is_notphone ()-Returns true when on batch tops or tablets
Wpmd_is_nottab ()-Returns true when on login tops or phones
Wpmd_is_notdevice ()-Returns true when on each tops only
Wpmd_is_phone ()-Returns true when on phones ONLY
Wpmd_is_tablet ()-Returns true when on Tablets ONLY
Wpmd_is_device ()-Returns true when on phones or tablets but NOT destkop
Wpmd_is_ios ()-Returns true when on an iOS device
Wpmd_is_iphone ()-Returns true when on iPhones
Wpmd_is_ipad ()-Returns true when on iPads
Wpmd_is_android ()-Returns true when on Android
Wpmd_is_windows_mobile ()-Returns true when on Windows Mobile
For example:
12345678910111213 |
<?php if (wpmd_is_phone()){ ?> <div> Visible only on mobile phones </div> <?php } else if (wpmd_is_tablet()){ ?> <div> Content visible only on tablets </div> <?php } else { ?> <div> PC-only visible content </div> <?php } ?> |
Original article, reprinted Please note:Reposted from Wu chuanbin's blog http://www.mr-wu.cn/
Link:How wordpress determines whether the phone, tablet, or PC, and displays the corresponding content-Mobile Detect http://www.mr-wu.cn/mobile-detect-wordpress-plugin/