Wordpress wp_nav_menu代码显示子页面

Using the wp_nav_menu function I need to achieve the following list structure.

  • Page 1
    • page 1 child
    • page 1 child
    • page 1 child
  • Page 2
    • page 2 child
    • page 2 child
    • page 2 child
  • Page 3
    • page 3 child
    • page 3 child
    • page 3 child

For some reason I cannot work this out and I am sure I have done this successfully in the past.

Any help/snippets would be greatly appreciated.

It's important I use the wp_nav_menu function and not list pages.

Thank you.

Dan

you can use below code:

wp_nav_menu(array('depth'           => 1) );

and add css code for layout

On my project I'm simply using Hierarchical Pages Widget which makes collapsing hierarchical pages/category/taxonomy lists exactly the one you need.

This plugin is also quite simple as it has only 1 php file.

UPDATE:

If you want to code something like that yourself, check out this article which shows how to create Hierarchical WordPress pages menu.