You could solve this with other nasty hacks but here’s kind of WordPress way:
In your header.php
<?php
// User is not using mobile
if( ! wp_is_mobile() ) {
wp_nav_menu(); // Your "original menu"
}
// User is using mobile
else if( wp_is_mobile() ) {
wp_nav_menu(); // Your another menu that only has top level items
}
?>
Keep in mind that wp_is_mobile()
also considers tablets as mobile devices and you should always carefully think this through because if PC window is resized to small / narrow -> it obviously doesn’t count it as mobile.
And jQuery to disable your click event:
var isMobile = false;
// Check if user is using mobile device
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
isMobile = true;
}
if( ! isMobile ) {
// Your usual click event
}
Related Posts:
- Convert WP Menu to a Drop Down for Mobile browser
- Translate a word in a responsive menu
- Responsive menu gone on wordpress Responsive theme
- magic “MENU” button under Twenty Twelve theme
- Responsive dropdown menu with smaller screen sizes
- Change Menu Button Text [closed]
- Responsive menu on genesis theme [closed]
- Efficient wp mobile menu
- Cannot collapse a responsive menu in WordPress
- Mobile menu displays submenus on top of parent. Need it to display right below on an own line
- Bootstrap navbar responsiveness on WordPress theme menu not working
- menu mobile show up even i in desktop mode in Newspaper Theme
- Image menu on responsive WordPress
- Customizing Responsive Themes Menu [closed]
- Navigation menu, remove item from desktop
- What is the best way to incorporate responsive dropdown navigation menu into custom theme?
- How can I only show one responsive menu on mobile devices?
- Is there an easy way to replace a custom menu link with a page or post?
- Why do Custom Nav Menus generate so many classes on list items? Can I manage this somehow?
- Custom search filter causes menu and query_posts problems
- Using nonce in menu item
- How do I add nested categories to drop-down menu in twenty-eleven?
- How show sub menu only using wp_nav_menu()
- How to add menu to Dashboard that can be viewed by all users
- List children of second level sub page
- Show top-level parent with submenu menu walker
- Add section to custom menu panel
- Adding menu items dynamically using wp_nav_menu_objects
- BuddyPress – How to add logout in nav menu
- Highlight the “Home” / “Blog” button while on main page
- How to remove div container in custom menu?
- how to add Custom menu item like User name in Header Menu only
- Menus – Open items in new tab/window?
- Highlight another nav item
- How to translate menu items?
- echo same menu items across multi-site platform
- Custom Menu url is Empty
- Get category ID from nav menu
- Menus don’t appear in admin area / WordPress Multisite
- Programmatically add existing pages and subpages to Appearance Menu
- Highlight current post ancestor parent menu items
- Ad custom admin page like WordPress customizer [closed]
- wp_nav_menu() doesn’t work
- Insert other menus as submenus of a main menu
- Appearance Menus Screen – menu item drop down menu not functioning
- Weird behaviour on Edit Menus screen
- Make a navigation menu in the same post [duplicate]
- Count within foreach loop
- How to actually make menu walker alive on admin interface?
- Highlight parent if item from submenu is active
- How to exclude pages in the menu without pageID?
- Why Isn’t My WP_Nav_Menu returning false?
- changing host.. data loss
- Theme Location empty
- How to buid wordpress menu with auto width sub-menu items in dropdown menu without any items sharing one line [closed]
- How to avoid a duplicate query from using wp_nav_menu?
- Wrapping menu’s top-level link and sub-menus in div
- Menu on mobile version doesn’t collapse after choosing menu item [closed]
- If test for “has_nav_menu()” does not return echo when no menu exists
- If current menu item is child or parent with child?
- Is it possible to dynamically register menus?
- Dynamic menu wp_list_pages displaying only current branch including: current page, his siblings and its childs
- Parent Page > Child Page Menu
- Opening Menu link in another tab
- How to add class to anchor using wp_nav_menu
- Page header menu links change
- Is it possible to link to the same page from wordpress page menu?
- Remove current-menu-item for a specific link
- How do I add 3rd level of dropdowns to wp_nav_menu array?
- insert div into a menu item before the link and more
- How to remove empty menu space when creating admin page without menu title using add_submenu_page
- WordPress + Bootstrap: Replace primary navigation menu on mobile?
- Multisite Setup – Menu Items To Reference Pages in Different Subdomains
- changin the url (permalink as it goes these days) on one specific menu layer
- Admin: WooCommerce Navigation Menus do not show empty categories search tab
- Using Anchor Link In Nav Menu
- WordPress database issues – menu not saving correctly, media thumbnails not showing
- How do I create a new directory to hold the assets for a new menu item?
- How to set active class to the menu of any page coming from a single.php template
- Parent link need to go first child submenu
- Sum root term’s entries count from child terms count
- Add newsletter signup element to navigation bar
- All custom links suddenly lack href attributes
- wp_nav_menu custom Page class
- WordPress – Apperance > Menu
- How to stop showing menu in static home page
- How do I add a link to the menu that has a charector (?) in it?
- Problem with custom menus
- Second tier sidebar navigation
- how to show a custom taxonomy as dropdown in wordpress?
- Problem to asign class to with wp_nav_menu()
- Site with all content on the front page
- Changing color of specific tab of top menu
- how to add fa fa icons customize menu using wp_nav_menu function?
- Why is my hamburger menu not shown? [closed]
- Jquery dropdown menus working locally, but not in WordPress [duplicate]
- Wrapping my ‘s with
- One item on menu is not clickable when it should be
- Critical Error when editing menu
- I need to change the hyperlink attached to the logo on the mobile menu