• My site structure is something like this:

    * Home
    * Employees
    ** Design
    *** Designer 1
    *** Designer 2
    ** Engineering
    *** Engineer 1
    *** Engineer 2
    *Contact Us

    I want to show a nested menu of subpages in my template.

    For example, when viewing the Employees page, the menu should show:
    * Employees
    ** Design
    ** Engineering

    When viewing the Design page, the menu should show:
    * Employees
    ** Design
    *** Designer 1
    *** Designer 2
    ** Engineering

    When 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)
  • if you are using wordpress 3.0.1 than all you need to do is create the pages and create custom menu and add them in that menu as you want and drag them as child and grandchild as you want.

    No need to code it your self.

    Thread Starter thv20

    (@thv20)

    As far as I’m aware that’s a manual/static solution?
    I’m looking for something that will work dynamically across the whole site – dozens and dozens of menus.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘List Parents, Children and Grandchildren in nested list’ is closed to new replies.