List Parents, Children and Grandchildren in nested list
-
My site structure is something like this:
* Home
* Employees
** Design
*** Designer 1
*** Designer 2
** Engineering
*** Engineer 1
*** Engineer 2
*Contact UsI want to show a nested menu of subpages in my template.
For example, when viewing the Employees page, the menu should show:
* Employees
** Design
** EngineeringWhen viewing the Design page, the menu should show:
* Employees
** Design
*** Designer 1
*** Designer 2
** EngineeringWhen viewing the Designer 1 page, the menu should remain the same.
This is what I have so far. It’s getting there, but I’m stuck now ??
<?php if($post->post_parent) { $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"); $titlenamer = get_the_title($post->post_parent); $titlelink = get_permalink($post->post_parent); } else { $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0"); $titlenamer = get_the_title($post->ID); $titlelink = get_permalink($post->ID); } if ($children) { ?> <ul id="subnav"> <li><a class="parent_page_item" href="<? echo $titlelink ?>"><? echo $titlenamer ?></a></li> <?php echo $children; ?> </ul> <?php } ?>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘List Parents, Children and Grandchildren in nested list’ is closed to new replies.