displaying subpages
-
i have a site where i’m trying to display JUST a list of the page children and grandchildren, with a heading at the top that’s the page parent.
this isn’t too hard, but i want the list of the parent at the top, the children (and nested grandchildren) to show up on every page within that branch (i.e. on the parent page, the child pages, the grandchildren pages).
i can get it work if it’s 2 levels, but if you click on the 3rd level deep, it shows child as the parent in the title.
suggestions? is there a plugin or hack to do that?
here’s the code:
<div id=”subnav”>
<?
$thispage = $wp_query->post;
$page = $wp_query->post;
$parent_name = $wpdb->get_var(“SELECT post_name FROM $wpdb->posts WHERE ID = ‘$page->post_parent;'”);if ($thispage->post_parent!=0) { ?>
<h2><? echo ($parent_name); ?></h2>
- <? wp_list_pages(“title_li=&child_of=”.$thispage->post_parent); ?>
<? } else { ?>
<h2><? echo ($thispage->post_name); ?></h2>- <? wp_list_pages(“title_li=&child_of=”.$thispage->ID); ?>
<? } ?>
</div><!–subnav–>
- The topic ‘displaying subpages’ is closed to new replies.