How does wordpress determine whether it is a mobile phone, tablet or PC access and display targeted content? Show specific content? 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 WP Mobile Detect plugin
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, then select "WP Mobile Detect" on the search results page and install it.
How to use WP Mobile Detect
Annotate it with [keyword] in the wordpress article editor, for example
Or use functions in php code to make judgments
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 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:
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/