Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I ended up using this:</p> <pre><code>&lt;?php /* USER-AGENTS ================================================== */ function check_user_agent ( $type = NULL ) { $user_agent = strtolower ( $_SERVER['HTTP_USER_AGENT'] ); if ( $type == 'bot' ) { // matches popular bots if ( preg_match ( "/googlebot|adsbot|yahooseeker|yahoobot|msnbot|watchmouse|pingdom\.com|feedfetcher-google/", $user_agent ) ) { return true; // watchmouse|pingdom\.com are "uptime services" } } else if ( $type == 'browser' ) { // matches core browser types if ( preg_match ( "/mozilla\/|opera\//", $user_agent ) ) { return true; } } else if ( $type == 'mobile' ) { // matches popular mobile devices that have small screens and/or touch inputs // mobile devices have regional trends; some of these will have varying popularity in Europe, Asia, and America // detailed demographics are unknown, and South America, the Pacific Islands, and Africa trends might not be represented, here if ( preg_match ( "/phone|iphone|itouch|ipod|symbian|android|htc_|htc-|palmos|blackberry|opera mini|iemobile|windows ce|nokia|fennec|hiptop|kindle|mot |mot-|webos\/|samsung|sonyericsson|^sie-|nintendo/", $user_agent ) ) { // these are the most common return true; } else if ( preg_match ( "/mobile|pda;|avantgo|eudoraweb|minimo|netfront|brew|teleca|lg;|lge |wap;| wap /", $user_agent ) ) { // these are less common, and might not be worth checking return true; } } return false; } ?&gt; </code></pre> <p>and then:</p> <pre><code>&lt;?php $ismobile = check_user_agent('mobile'); if($ismobile) { wp_nav_menu( array( 'theme_location' =&gt; 'mobile' ) ); } else { wp_nav_menu( array( 'menu' =&gt; 'primary', 'container' =&gt; '', 'menu_id' =&gt; 'menu' ) ); } ?&gt; </code></pre> <p>This doesn't work on the device size but rather whether or not the site is being accessed from a mobile device.</p> <p>Source: <a href="https://stackoverflow.com/questions/6524301/detect-mobile-browser">Detect mobile browser</a></p> <p>Thanks<br> Willem</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload