I want to have two different menus for desktop and mobile phone users.
So, I have created two places for two menus (primary, mobile) with this function:
functions.php:
function is_register_my_menus() {
register_nav_menus(
array(
'primary' => __( 'primary' ),
'mobile' => __( 'mobile' )
)
);
}
add_action( 'init', 'is_register_my_menus' );
So far, so good. I could create another menu with one item left out and set that menu as "mobile".
Then I installed the Wordpress plugin PHP Browser Detection, which works just fine. With that I tried to have a switching/exchange of those two menus, depending on the device.
header.php:
<nav id="nav" role="navigation" class="gross">
<div id="knopf"><a href="#"></a></div>
<?php if ( is_mobile() ) { wp_nav_menu( array('menu' => 'mobile' ) ); } else { wp_nav_menu( array('menu' => 'primary' ) ); }; ?>
</nav>
Unfortunately, it shows always the primary menu, regardless of computer/desktop or mobile device. Did I do something wrong in the if/else code? I use that on my posts to exchange post_thumbnail per device, as well, and there it is working fine.