Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm going to test the user agent to load a mobile template instead of the desktop theme.

There are many mobile detection scripts out there.

  • Does wp_is_mobile() function work well?
  • What is your experience in comparison with other classes like e.g.
share|improve this question

2 Answers 2

up vote 12 down vote accepted

Yes it works well. It's a very simple function but never found a mobile device not recognized by it. It recognize the 90%+ of mobile devices. Main difference from is that doesn't differe from phone and tablets.

See the code

share|improve this answer
thank you, as always G.M. provides pro answers :) –  Andrea Puiatti Aug 26 '13 at 14:46
thank you, Andrea @AndreaPuiatti –  gmazzap Aug 27 '13 at 0:23

Yes, the wp_is_mobile() works well, but you can run into problems when using aggressive caching systems, such as fastcgi, proxy cache, etc. that skip the php execution.

If that is the case, I would recomend some client side (javascript) detection method that is loaded for both mobile and desktop browsers.

share|improve this answer
That's a good point. If you use full page caching in auto (per request) mode, the cache will contain mobile OR desktop version, depending on what device the first request was made from. All further requests will be served with this version, no matter what device type it is. If you use a pre-caching solution (which I always do), you'll get desktop versions generated and mobile users will always get them. –  Ihor - May 8 at 14:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.