Skip to content

Instantly share code, notes, and snippets.

@palpalani
Created June 28, 2014 07:27
Show Gist options
  • Save palpalani/c77657fe7a224e031379 to your computer and use it in GitHub Desktop.
Save palpalani/c77657fe7a224e031379 to your computer and use it in GitHub Desktop.
WordPress - Detecting Mobile Visitors of Your Website
Like strip_shortcodes(), wp_is_mobile() is also easy to explain: It allows you to detect users that are using mobile devices to connect to your website.
Usage
<?php
if( wp_is_mobile() ) {
// echo the "HAVE YOU TRIED OUR AWESOME MOBILE APP?" banner
} else {
// don't echo the banner
}
?>
A perfect Adaptive Web Design tool, if you ask me. Plus, you can remove some elements that are irrelevant for mobile users, or add some like a banner for your mobile application.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment