Now that’s what I call a long title! So this is just a quick post on how to get WordPress to list all parent pages and subpages in order when using the wp_list_pages function. I’ve recently added a child page to my Development/Web/ page and it broke the existing navigation I had. I tried the ‘$post->ancestors’ based solution on the WordPress function reference but that made things worse so here’s my solution:
So my solution takes the ‘$post->ancestors’ array and reverses it (though keeping the child array keys the same) then I do a foreach loop to spit out each unordered list. This results in each tier of navigation appearing one after the other, but only for that particular page.
