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
- Nav walker bootstrap: Display 3rd level and 4th level in dropdown menu
- wp_nav_menu parent in submenu
- How to add toggle-able DOM element after nav menu item?
- Display a portion/ branch of the menu tree using wp_nav_menu()
- Programmatically add a Navigation menu and menu items
- Dynamically exclude menu items from wp_nav_menu
- Split up wp_nav_menu with custom walker
- Is there an easy way to replace a custom menu link with a page or post?
- How to Add to Each Menu Link with link text to data-attr?
- Add Javascript to WordPress Menu
- Add custom menu item using wp_nav_menu_items filter
- Filter wp_nav_menu()
- How to modify navigation menu of the “My Account” page in WooCommerce
- Custom ID for certain menu item?
- how to create a menu with all sub categories?
- Add data-icon input to WordPress custom menu links
- Add separator to admin submenu
- Display only page specific sub menu items using Custom Walker
- Removing link ” from ” menu for some “links” without JS
- Show current navigation path from menu
- Call custom field into menu item
- Use navigation path from menu for permalink
- Exclude Private, Draft pages from Primary Nav when using custom menu
- add span class inside wp_nav_menu link anchor tag
- Add a .last class to the last in each ul.sub-menu
- wp_nav_menu always falls back to a menu
- wp_get_nav_menu_items how to exclude sub level menu items?
- Add class to top level menu item if it has multiple child levels
- How to set limit only on top levels of wp_nav_menu?
- Determine if a navigation item has children
- How show sub menu only using wp_nav_menu()
- Keeping parent menu items active in child pages
- Bootstrap dropdown nav pills not working with wp_nav_menu()
- How to move parent li to end of child ul
- How to get a different mobile menu than desktop menu in the twentytwelve child theme
- Add custom attributes to menu items without plugin
- Simple Navigation Walker – Wrapper-class around first sub-menu
- How to get a separate child menu?
- Breadcrumbs showing Parent and Child Pages
- Exclude one item from wp_list_pages( $args );
- Add Page ID class to nav menu items
- wp_nav_menu() loses ‘current-menu-*’ classes on single product page within category
- How to highlight the right item in the navbar
- HTML Bootstrap navigation menu to WordPress menu using wp_nav_menu
- How to drag multiple menu items at once in WordPress?
- Customizing the a tag with Semantic UI
- How to manually add an item to a submenu in a menu generated by wp_nav_menu?
- WordPress Export Import Site Navigation Menu
- Using Image Links in WordPress Navigation Menus Instead Of Text Links
- Links open only on new tab or window
- Put a wp_nav_menu inside another one