I think there’s couple of ways doing this.
1) register_nav_menu
, add your menu in Appearance > Menus to the registered menu location, then let wp_nav_menu
handle the markup for you
2) register_nav_menu
, add menu in Appearance > Menus, then use wp_get_nav_menu_items
to get the menu items and write the html markup yourself.
3) Have an $array
of parent page ID’s (hardcoded or get them from an option/post_meta/wherever), do for/foreach/while
loop with the array and use get_children
inside it. You can either use to loop to simultaneously build the html markup or store the parent and child ID’s to another $array
and do the html loop later with it.
Related Posts:
- How to have custom menu Item CSS Classes for wp_page_menu() or wp_list_pages()
- Show just one level of child pages, wp_list_pages woe
- Multi Level Bootstrap Navigation Menu in WordPress
- Show only 2nd level of navigation depending on active navigation
- Custom Nav Walker sub-menu HTML construct
- Adding different classes to anchor in navigation menu
- how to automatically generate hierarchical menus from hierarchy of pages?
- Handling complex multi-level architecture / menu for large site
- How to display dynamic content in start_lvl function
- wp_list_pages: only show subpages on the parent page?
- Menus like a CMS
- How to add a submenu toggle button inside all “li” elements that have a submenu?
- Check if menu id = $specific_id – then insert specific
- Highlight another nav item
- wp_nav_menu() with multiple Class
- Schedule Page to Menu [duplicate]
- Trying to Create Menu in WordPress
- How do I add recent posts to the menu?
- Automatically list top level menu item child pages
- Programmatically add existing pages and subpages to Appearance Menu
- How to retrieve parent menu item name of current submenu item
- Check if menu_item has children or has parent
- Combining ‘depth’ with ‘include’ in wp_list_pages()
- How to highlight 1st level menu item based on actual page
- Add a submenu to wp_nav_menu
- How to buid wordpress menu with auto width sub-menu items in dropdown menu without any items sharing one line [closed]
- Adding toggle-able element after menu item
- How to Add support for sub-menu item description in wordpress?
- Dynamic menu wp_list_pages displaying only current branch including: current page, his siblings and its childs
- wp_list_pages Hierarchical Help
- How to use wp_list_pages on a grandparent page
- Add Different Class on Different Ul in twenty-twentyone theme
- wp_nav_menu container style args
- Bootstrap Theme Migrated to WordPress
- WordPress + Bootstrap: Replace primary navigation menu on mobile?
- How can I click the parent menu then redirect to a special URL?
- Where to place a svg chevron down in my custom walker?
- Add href to tag in nav menu for mobile
- Conditional Nav Menu Inside Nav Menu Across Multisite Sites
- How to sort a sub-menu, generated with get_pages(), by the page order instead of alphabetically?
- Show Child of Parent Page including all other parents
- How to display list of child pages with parent in wordpress?
- nav_menu: how to force a subpage switching on the parent menu
- Display all submenus
- Second tier sidebar navigation
- How was this menu system created?
- Display sub menus as separate lists
- How can I structure my pseudo footer nav code with wordpress codex code?
- Give custom class names to WP nav sub-menu
- Show current navigation path from menu
- Exclude one item from wp_list_pages( $args );
- Put a wp_nav_menu inside another one
- Add class to active top level (grandparent) menu item
- Generate a Menu that displays all child pages of top level parent
- Check if wp_nav_menu items have submenus
- How to get Menu Navigation Labels to output HTML
- custom menu not found
- wp_nav_menu doesn’t generate parent/ancestor classes
- Benefits of using Nav Walker?
- Use walker for specific menu, or avoid use of walker
- Change where navigation bar links?
- has_children in custom nav_walker
- No “current-menu-ancestor” class added when browsing an archive page
- Change an li class name in a wordpress custom menu walker
- Menu with parents, children and or siblings pages display
- Separator for custom nav menu
- add_submenu_page function to show videos table
- Nav and logo loading each time causing menu to move JointsWP – Foundation 6
- Using _s theme, menu changes do not affect header menu
- Show children (sub-navigation) of active menu item only
- Menu Arrow for Child Element
- Adding an external link to wordpress menu
- Add a counter beside menu item label
- Twenty Fifteen: Change navigation menu behavior
- Odd spacing in Navigation Bar [closed]
- How to avoid the and which added when custon menu widget is used
- Add pages content to startpage through custom menu
- An alternative to WordPress’s built-in menu functionality
- Can you exclude child pages of a specific parent within a navigation?
- Is there any way to change the CSS class applied to 2nd level sub menu ul’s?
- Check if page has subpages
- How to change how WordPress renders navigation menu on Block Themes
- Problem with links once in portfolio item
- Get Each Menu Nav Label of Menus in HTML tag
- insert an HTML element if there is a submenu only
- How do I display menu in header without loosing styles?
- Getting parent object_id of child menu items in WordPress menu
- display cart information within li of cart menu item
- Add data-track to links in menu
- Is it possible to seperate wordpress menu by different div?
- How to add odd and even classes to all nav links through walker?
- Output sort number in wp menu list item?
- Check in walker if current page is descendant
- Active page link not getting class assigned
- Customize Walker_nav_menu to show posts if item is category
- Menu not always using correct link
- Menu support for touch devices
- How to make an anchored page in a navigation menu tab
- Two Homes In Navigation Menu
- How to set menu Display location