Archived topic
Different mobile menu?
7 replies · Started by leo on April 3, 2016
Is it possible to use a different menu for mobile?
It depends.
If you're using the Slideout menu, you can set it as a theme location in "Appearance > Menus".
If you're using the Mobile Header, there's a simple filter I can provide.
If you're using the default mobile menu, I'm afraid it uses the same menu as desktop.
Let me know :)
I know. I used the Slideout menu first, but the dropdown for submenus only works when you click on the arrow precisely (on mobile). So I switched back to the default menu, where you can hit the bar anywhere to get the dropdown.
It's not a very big deal, but if it's not too much trouble, I would be interested in your filter.
Thanks Tom!
Edit for Tom: the menu you see on the homepage is the menu for visitors. Logged in users have many more options.
The mobile menu should act the same regardless of slideout vs regular. If your menu item has # as the URL, you should be able to tap the entire item to initiate the dropdown. This is a feature in the latest version.
To create a new theme location for the mobile header, you need to do something like this:
add_action( 'init', 'generate_register_mobile_menu' );
function generate_register_mobile_menu() {
register_nav_menu( 'mobile-menu',__( 'Mobile Menu' ) );
}
Then you need to add this:
add_filter( 'generate_mobile_header_theme_location', 'generate_change_mobile_header_menu' );
function generate_change_mobile_header_menu()
{
return 'mobile-menu';
}
Adding PHP: https://generatepress.com/knowledgebase/adding-php-functions/
Wow man, this is Support 3.0. The # did the trick.
Thanks a million!
You're welcome :)
I'd like to ask a related question here, even though the thread is more than a year old.
I created a new menu ("TestMenu") that is not assigned to any of the three locations (Primary, Secondary, or Slideout). I would like to use "TestMenu" as my mobile menu instead of the default, which is the Primary menu.
I added the two code snippets provided above, and I now have "Mobile Menu" under Appearance->Menus->Manage Locations, and I can select my "TestMenu" as an option.
But I don't know what to do next. The Primary menu still shows up in the mobile context. Are there additional steps, or is what I'm trying to do not possible?
Thank you --
Hi there,
Best way is to assign the new menu to be slideout menu, then activate it for mobile only:
https://docs.generatepress.com/article/activating-slide-out-navigation/