$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>menus - Creating navigation out of specific IDs and their children?|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

menus - Creating navigation out of specific IDs and their children?

matteradmin7PV0评论

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 badges
Add a comment  | 

1 Answer 1

Reset to default 0

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.

Post a comment

comment list (0)

  1. No comments so far