With all of the new web enabled devices springing up in the market and with the wide range of screen sizes and data transfer speeds, a website can no longer serve the same content upon every request (not without some degree of limitation and/or traffic-loss).
This lightweight plugin lets content writers and theme authors choose when WordPress should or shouldn’t show any give content item using shortcodes and quicktags or theme elements using functions. It uses Mobile Detect (a PHP script) to identify the website visitor’s device as either mobile, tablet or desktop, enabling you to allow or disallow content to be output. Use it to prevent large files such as images from outputting to devices that generally have a lower data transfer speed available to them (e.g. mobile devices). Serve more extensive copy and more elaborate userinterfaces to desktop devices and laptops. Target tablets to market a tablet oriented product or service. You can also detect iOS, iPhone, iPad, Android OS and Windows Mobile OS.
Example of a shortcode: [notmobile]Write anything you want between these two tags and WordPress will only output it when the visitor is viewing your website with a desktop/laptop or tablet and not with a mobile device.[/notmobile]
Easily add these shortcodes using the Quicktags in Text view.
All shortcodes also exist as functions (prefixed with aFAC_ for namespacing), which can be used in your theme as needed. See the FAQs for more detail. Each function is a boolean and simply returns true or false.
This section describes how to install the plugin and get it working.
- Upload the
addfunc-adaptive-contentfolder to the
- Activate the plugin through the ‘Plugins’ menu in WordPress
- Start using the shortcodes in your content and/or the functions in your theme
- What shortcodes are available with AddFunc Adaptive Content?
All available shortcodes are documented in the Help tab under «Adaptive Content» (on the content editing page).
- What functions are available with AddFunc Adaptive Content?
- aFAC_mobileonly() — Returns true only when device is mobile (and not tablet)
- aFAC_notmobile() — Returns true only when device is not mobile (or is tablet)
- aFAC_tabletonly() — Returns true only when device is tablet
- aFAC_nottablet() — Returns true only when device is not tablet
- aFAC_desktoponly() — Returns true only when device is not mobile (and not tablet)
- aFAC_notdesktop() — Returns true only when device is mobile (or is tablet)
- aFAC_iosonly() — Returns true only when device is iOS
- aFAC_iphoneonly() — Returns true only when device is iPhone
- aFAC_ipadonly() — Returns true only when device is iPad
- aFAC_androidonly() — Returns true only when device is Android OS
- aFAC_windowsmobileonly() — Returns true only when device is Windows Mobile OS
- Does AddFunc Adaptive Content rely on PHP for anything?
- Does AddFunc Adaptive Content work by browser sniffing?
Yes. That is what it’s base script (Mobile_Detect.php) is designed for and it does the job well.
- Wouldn’t it be better to serve up images at an appropriate size based on the screen size or image area width, rather than the device type?
Yes. That’s quite a trick and we would love to see someone develop a plugin which makes that easy. I haven’t found one yet.
Contributors & Developers
“AddFunc Adaptive Content” is open source software. The following people have contributed to this plugin.Contributors
Interested in development?
- Adds Quicktags
- Includes updated Mobile_Detect.php to the latest stable release (2.8.19)
- Includes updated Mobile_Detect.php to the latest stable release (2.8.16)
- Includes updated readme.txt (hereafter goes without mention)
- Submitted to WordPress repository
- Repurposed WP Mobile Detect as AddFunc Adaptive Content, to alter the shortcodes and to reinstate maintenance of this valuable plugin