How does wordpress determine whether a Mobile phone, tablet, or PC is displayed and the corresponding content is displayed-mobile Detect, wordpress-Mobile

Source: Internet
Author: User

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/

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.