How does WordPress determine whether a mobile phone, tablet or PC is accessed and targeted to display specific content? Mobile Detect This lightweight PHP class library is a great feature to implement. And mobile Detect also has WordPress under the plugin can be used –WP mobile detect,wordpress Use this plug-in, it is easy to achieve a different terminal device to display specific content functions, such as responsive WordPress theme.
Installing WP Mobile DETECT plugin
Login to WordPress management background, in the Plugin management page, select "Install plugin", and then search box enter the keyword "WP mobile Detect", and then search results page li select "WP mobile Detect" and install.
Installing WP Mobile DETECT plugin
Search WP Mobile Detect plugin
WP Mobile detect how to use
In the WordPress article editor, use [keywords] to annotate, for example
Mobile Detect How to use
Or you could use a function to judge in PHP code.
Wpmd_is_notphone () –returns True when on desktops or tablets
Wpmd_is_nottab () –returns True when on desktops or phones
Wpmd_is_notdevice () –returns True when on desktops 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 and not Destkop
Wpmd_is_ios () –returns True when on 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:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
if (wpmd_is_phone()){ ?>
仅手机可见内容
else if (wpmd_is_tablet()){ ?>
仅平板电脑可见内容
else { ?>
仅PC可见内容
|
Original articles, reproduced please specify: Reproduced from Wuchuanbin blog http://www.mr-wu.cn/
This article link address: How to judge the mobile phone, tablet or PC and display the corresponding content-mobile Detect http://www.mr-wu.cn/mobile-detect-wordpress-plugin/
The above describes how WordPress judge mobile phone, tablet or PC and display the corresponding content-mobile Detect, including the aspects of the content, I hope that the PHP tutorial interested friends to help.