I'm a bit confused about wp_list_pages()
function.
Lets say I have 3 top level pages (with no parent) and each of them have some sub-pages:
- page 1 [sub-pages: 1.1, 1.2, 1.3];
- page 2 [sub-pages: 2.1, 2.2, 2.3];
- page 3 [sub-pages: 3.1, 3.2]
What I'm trying to do is to display top level pages 2 and 3 with all their subpages:
wp_list_pages( 'sort_column=menu_order&depth=0&title_li=&include=2,3' );
I have also tried so specify the depth as depth=2:
wp_list_pages( 'sort_column=menu_order&depth=2&title_li=&include=2,3' );
However, the top level pages 2 and 3 are displayed with no subpages. I'm not sure if I understood the function description correctly.
How do I achive such functionality when sub-pages can be added/deleted at any time.
Many thanks, Dasha
include
you're explicitly setting which pages to return in the result, so you're basically limiting the result to those two pages.exclude_tree
? eg:wp_list_pages( 'exclude_tree=N&yourotherargs=something' )
where N would be an ID of the top level page to exclude.include
option and collecting all the pagesids
to be displayed.