Skip to content

Instantly share code, notes, and snippets.

@tahirtaous
Created January 25, 2015 14:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tahirtaous/b0a33d3640a0ab990824 to your computer and use it in GitHub Desktop.
Save tahirtaous/b0a33d3640a0ab990824 to your computer and use it in GitHub Desktop.
This is a little-known built-in function of WordPress that detects whether a user is visiting on a mobile device or not and allows to display content accordingly. It is quite handy function for those willing to include a bit of code for only mobile users.//
// This code will show message only on mobile devices
// only mobile users will see this message
// Source: https://www.cms2cms.com/blog/6-useful-yet-relatively-unknown-wordpress-functions/
// Tested: WordPress 4.1 Jan 25 2015
<?php if( wp_is_mobile() ) : ?>
Visit our website on your desktop for a richer user experience
<?php endif ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment