The easiest way to detect the mobile devices using wordpress is to use in built function wp_is_mobile().
Often when working on responsive web design and websites its needed to detect the mobile devices and write code specifically for mobile devices only. wp_is_mobile() detects if user is visiting via mobile devices and returns TRUE or FALSE condition.
Example usage:
[code language="php"]
<!--?php if ( wp_is_mobile() ) { // Do something in here } ?-->
[/code]