My wordpress blog contains the following Page hierarchy:
- page 1
L page 1.1
L page 1.2
- page 2
- page 3
I display a menu on my page.php template so that i can show a parent’s child items, and a child’s upper parent level, like this:
if($post->post_parent){
$page = get_page($post->post_parent);
$categoryTitle = $page->post_title;
$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
}else{
$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
}
Now there was a need recently to add an additional sublevel of pages, thus turning the system into:
- page 1
L page 1.1
L page 1.1.1
L page 1.1.2
L page 1.2
L page 1.2.1
- page 2
- page 3
Problem is: if i’m on a page x.x.1 i don’t see page x in the menu, only the x.x parent.
Anyone has an idea on how to get all parents and children of a page ?
There are a few plugins which you could look at for that functionality, if not flat-out use:
http://wordpress.org/extend/plugins/flexi-pages-widget/
http://wordpress.org/extend/plugins/gd-pages-navigator/
http://wordpress.org/extend/plugins/search.php?q=sub+pages
Good luck, hope these help!
i ended up developping a specific page template per tree branch. ( “page x” items ). with that, i could just hardcode the page parent id in the string wp_list_pages(“title_li=&child_of=16&echo=0”); and there, it works. The plugin suggestion is not bad, but for simple things like that, i prefer not to rely on someone else’s code.