Home > Article > Backend Development > How does wordpress determine whether it is a mobile phone, tablet or PC and display the corresponding content-Mobile Detect
How does wordpress determine whether it is accessed from a mobile phone, tablet or PC, and display specific content in a targeted manner? Mobile Detect, a lightweight PHP class library, can implement this function very well. Moreover, Mobile Detect also has a plug-in available under WordPress – WP Mobile Detect. WordPress uses this plug-in to easily implement the function of displaying specific content according to different terminal devices, such as responsive WordPress themes.
Install the WP Mobile Detect plug-in
Log in to the WordPress management background, select "Install plug-in" on the plug-in management page, then enter the keyword "WP Mobile Detect" in the search box, and then select "WP" on the search results page Mobile Detect" and install it.
Install the WP Mobile Detect plug-in
Search for the WP Mobile Detect plug-in
How to use WP Mobile Detect
Mark it with [keyword] in the wordpress article editor, such as
Mobile Detect How to use
or use functions in php code to determine
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 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:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
Original article, please indicate when reprinting: Reprinted from Wu Chuanbin’s blog http://www.mr-wu.cn/
Link address of this article: How does wordpress determine whether it is a mobile phone, tablet or PC and display the corresponding Content-Mobile Detect http://www.mr-wu.cn/mobile-detect-wordpress-plugin/
The above introduces how wordpress determines whether a mobile phone, tablet or PC is used and displays the corresponding content - Mobile Detect, including relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.