- This topic has 2 replies, 3 voices, and was last updated 6 years, 11 months ago by .
- The forum ‘General Discussion’ is closed to new topics and replies.
These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.
Is there a way to show a different menu when the site is viewed from a mobile device?
I would like to show certain menu items when viewed from a desktop and different ones when viewed from a mobile device.
I am using minimum pro
This is tricky, but it is doable. Menus are generated by PHP, a server-side process. PHP does not know or care what type of device your site is being accessed by. PHP generates code. That's all.
There are two ways that I know of where you can swap the menu. First, you could have a completely separate menu for mobile that is generated by PHP through a jQuery Ajax call after the page is initially loaded. This will be inefficient and cause a slight delay in the page display.
Second, you can create a single giant menu and assign different classes to the desktop and mobile items. Using jQuery, you can determine the device display and hide/show the menu items by looping through the menu and displaying the appropriate items. Don't forget to add the classes to sub-menus also, otherwise the display will be screwy.
As for the code, this will take a lot to figure out, maybe as much as half a day. If you're not too skillful with jQuery, you may want to think about hiring a developer.
There are several plugins that do exactly what you're looking for. I used ShiftNav on one of my sites.
© 2024 WPEngine, Inc.