• The structure of my site is as following

    <ul>
    <li>Master 1</li>
         <ul>
         <li>First Child 1</li>
         <li>First Child 2</li>
               <ul>
               <li>Second Child 1</li>
               <li>Second Child 2</li>
              </ul>
         </ul>
    <li>Master 2</li>
    </ul>

    When clicking on the Master 1, I correctly display the First Child 1 page. Also, adding depth=1 in the following code, I get to display only child pages of first level.

    The problem is that when I clink on First Child 2, I can not display the navigation with the second level child pages (Second Child 1 and 2).
    How should I do? I would also like to display this second level of child pages into a widget.

    The code I’m using is the following. Thanks

    <?php
      if($post->post_parent)
      $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0&depth=1");
      else
      $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0&depth=1");
      if ($children) { ?>
    <div id="sub-nav">
      <ul class="sub-nav" style="display:inline">
      <?php echo $children; ?>
    
    </div>
      <?php } ?>

Viewing 1 replies (of 1 total)
  • Thread Starter alexthecatta

    (@alexthecatta)

    PLS HELP! I’M LOST!

    I’ve done a little step forward, but again another problem. Here the situation at the moment:

    If I click on “Master 1” page, I correctly display in the navigation the two pages links at “First Child 1” and “First Child 2”, and user display immediately the First Child 1 page. And this is fine.

    Then if I click on “First Child 2” page, I correctly display in the navigation the links to “Second Child 1” and “Second Child 1” pages but:

    – user does not display immediately the “Second Child 1” page content
    – if I clik one of the links diasplayed in the navigation (Second Child 1 or econd Child 2) I completely loose the navigation described above.

    What I’m using now is two different templates, beside the default one.

    One template for

    <ul>
    <li>Master 1</li>
         <ul>
         <li>First Child 1</li>

    with the following code inside

    <?php
      if($post->post_parent)
      $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0&depth=1");
      else
      $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0&depth=1");
      if ($children) { ?>
    <div id="sub-nav">
      <ul class="sub-nav" style="display:inline">
      <?php echo $children; ?>
    
    </div>
      <?php } ?>

    and another template for the following pages

    <li>First Child 2</li>
               <ul>
               <li>Second Child 1</li>
               <li>Second Child 2</li>
              </ul>
         </ul>

    with the following code inside

    <?php
      if($post->post_parent)
      $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");
      if ($children) { ?>
    <div id="sub-nav">
      <ul class="sub-nav" style="display:inline">
      <?php echo $children; ?>
    
    </div>
      <?php } ?>

    PLS HELP ME! THANKS

Viewing 1 replies (of 1 total)
  • The topic ‘two level child page?’ is closed to new replies.