I'm looking for a way to list three specific pages in a nav-menu (I want to get these pages by their unique page ID's), and also list the children of these three pages - appended to each list item, in a 'ul' of their own (So like a standard multi-tiered sub-nav type menu).
I've been trying to do this with wp_list_pages()
, but child_of
only takes one argument.
Help would be appreciated!
I'm looking for a way to list three specific pages in a nav-menu (I want to get these pages by their unique page ID's), and also list the children of these three pages - appended to each list item, in a 'ul' of their own (So like a standard multi-tiered sub-nav type menu).
I've been trying to do this with wp_list_pages()
, but child_of
only takes one argument.
Help would be appreciated!
Share Improve this question edited Feb 15, 2019 at 14:19 W4yp01nt asked Feb 15, 2019 at 9:11 W4yp01ntW4yp01nt 13 bronze badges1 Answer
Reset to default 0I 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.