Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/wp is mobile


This Conditional Tag checks if the user is visiting using a mobile device. This is a boolean function, meaning it returns either TRUE or FALSE. Works through the detection of the browser user agent string ($_SERVER['HTTP_USER_AGENT'])


<?php wp_is_mobile(); ?>


This tag does not accept any parameters.

Return Value

Returns true or false based on the value of $_SERVER['HTTP_USER_AGENT'].


if ( wp_is_mobile() ) {
	/* Display and echo mobile specific stuff here */

You should realize that this does not detect a mobile phone specifically, as a tablet is considered a mobile device. Check the Plugins area for several helpful alternatives. It also should not be used for themes. This is perfectly fine to use in themes, however it is not a substitute for media queries, or styling per device. (http://wordpress.stackexchange.com/questions/188881/proper-usage-of-wp-is-mobile)

Change Log

  • 4.0 -- Works by testing HTTP_USER_AGENT for any of the following : [ Mobile, Android, Silk/, Kindle, BlackBerry, Opera Mini, OperaMobi ]. Does not consider resolution, window width, or any other factors.
  • Since: 3.4

Source File

wp_is_mobile() is located in wp-includes/vars.php.

Relevant Plugin

Relevant plugins in this area include:

  • The free Mobble plugin can provide even more granular mobile user-agent detection.
  • The free Mobile Smart plugin also offers user-agent detection
  • Are you a mobile plugin developer? Add your own here to the list...

See also index of Function Reference and index of Template Tags.