Your html structure should look like
<ul class="parent-class">
<li>Page 1</li>
<li>
<ul class="child-class">
<li> Sub menu item 1</li>
<li> Sub menu item 2</li>
</ul>
</li>
</ul>
WordPress should automatically add an “active” class to the active page then you should be able to style everything with css. Something like
.parent-class li ul {
Display:none;
}
.Active li ul {
display:block;
}
.parent-class:hover > .parent-class li ul {
display:block
}
Related Posts:
- Custom Nav Walker to show siblings and children of current branch?
- WordPress custom menu can’t show 3. level submenu
- WordPress menu walker – Get parent item text inside end_lvl function
- Menu items description? Custom Walker for wp_nav_menu()
- Add Caret to Menu Items with Sub-Menus in WordPress Theme
- Any walker causes blank menu?
- Extend walker – navigation, adding data attribute to a tag
- how to change WordPress menu markup/classes
- Custom Nav Walker Displaying Values in Sub Menu
- Find the Children of a Page then Echo it as a Bulleted List of Links (menu)
- Create wordpress header with custom logo in between the menu splitting the menu into two equal parts [closed]
- wp_post->post_parent object returning 0
- WordPress empty Nav Menu error
- Single-level menu option? Another way?
- Issue on Adding A Class to Bootstrap Navbar Walker Dropdown
- Custom Navigation build using wp_nav_menu and walker
- Admin: sub menu doesnt display under apperance when activate my themes
- Theme: dropdown hover menu not showing up in IE/Edge
- Show all menu levels except top level. How to exclude top level of a menu?
- WordPress doesn’t recognize submenus as so I can’t style them properly
- Horizontal Navigation
- Main Menu Theme Different Output Print
- Add wrapper for a specific sub-menu
- How to add posts to custom menus?
- Display Menu Name using wp_nav_menu
- How to limit wordpress menu depth in admin panel
- Display only page specific sub menu items using Custom Walker
- How do I check if a menu exists?
- How to use logout function on custom menu link?
- Add class to top level menu item if it has multiple child levels
- Simple Navigation Walker – Wrapper-class around first sub-menu
- How to display wp_nav_menu() conditionally only when not on a 404 page?
- Problem with registering menus – What to do when other solutions aren’t working?
- Add a #hash to the links in my custom menu
- How can i change menu link when page content empty?
- Check if wp_nav_menu items have submenus
- How to add (css) classes to only one wp_nav_menu()?
- Replace Home with image link inside custom header menu
- Displaying wp menus by name without using theme locations
- Nav walker, bootstrap: Display 3rd level items under 2nd level
- How do I add a post to a menu
- Best practices: Custom theme sidebar menu – hardcode or widget?
- Where is definied the theme location for the main menu in a WordPress template?
- Second menu not showing
- How to remove class attributes from custom menu markup?
- menu behavior is not as expected
- Part of Menu Item Hidden on Header Menu
- Main Menu and Sub Menu Items for Footer
- How to construct a custom html for submenus
- which is the best way to customize nav-menu-template.php?
- Get Current Menu Location inside Nav_Walker
- My Admin bar covers my sticky navbar [closed]
- WordPress is adding margins and padding to my custom menu?
- Menu item added in wp_nav_menu_items filter is never highlighted
- multisite: global menu containing network site links?
- Using a page as home, how do I prevent nav from setting both home and page links active?
- How to append to menu items selectively
- How to add ID attribute to each submenu?
- Custom Nav Walker Trouble
- Custom Nav Walker sub-menu
- Show woocommerce categories on my theme menu styling
- Change submenu markup
- getting the current sub item out of total sub items in a given dropdown (custom walker)
- Why does has_nav_menu return false when get_registered_nav_menus shows the opposite?
- Child Theme header1.php file not overwriting parent theme’s header1.php file
- 3 Level Deep Navigation Menu Not Showing All Levels
- How to Create custom xml file for demo content for custom theme?
- Add child pages to submenu automatically
- wp_nav_menu and its fallback
- Theme development – Automatically menu creation
- Theme development: How to add CSS classes to menu items?
- Navbar- disable “onClick” drop-down
- Some doubts about WordPress handle the horizontal main menu visualization
- How to conditionally add a wp_filter
- Remove/Hide a Widget on a Custom Template
- Parent/Child pages
- finding menu hierachy > wp_get_nav_menu_items
- How to substitute old wordpress menu by wp 3 menu the right way?
- Archives and Categories in Custom Menu
- Best way to give user the option to make a menu, mega menu?
- 3 Level Menu Navigation (3rd Level not displaying)
- Pages not displaying as sections on static page
- Displaying a part of a menu containing the page the user is currently viewing and only it’s immediate children
- Need help with adding custom wordpress menu and sub-menu
- How to achieve this navigation style in wordpress navigation
- HTML TO WP Theme : Submenu goes down wp_nav_menu
- Conditional Nav Menu Inside Nav Menu Across Multisite Sites
- Fallback dosen’t work when not using ‘menu’ attribute
- Primary Menu Showing All Pages With No Sub-Nav
- wp_nav_walker that interacts with widgets to setup mega menu
- After theme change the menus have to be manually linked to the corresponding theme location
- WordPress 3.9 two menus in same position?
- What’s the policy for building a theme that doesn’t support widgets/menus?
- How can I change the title of the Home link in the navigation bar?
- How to make navigation a list without a plugin? [duplicate]
- How to highlight current menu bar base on the URL?
- Global Navigation menu in diiferrent wordpress setups
- How to create sub-menu in “Allure Real Estate Theme for Placester”?
- Dynamic nav menu with icons [closed]
- Why is wp_nav_menu() not removing the container around the nav ?