WordPress How to judge the phone, tablet or PC and display the corresponding content-mobile Detect

Source: Internet
Author: User
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()){ ?>

仅手机可见内容

elseif(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.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.