WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Custom List Pages Argument (4 posts)

  1. mitchrenton
    Member
    Posted 5 years ago #

    Hi Guys, I wonder if anybody can help me out here...

    I want to display the sub pages of the given page. Then if I am on a subpage, I want to display the other pages on that level beneath the page parent. Here's the code I have so far...

    <?php
      $children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0');
      if ($children) { ?>
      <ul>
      <?php echo $children; ?>
      </ul>
      <?php } else; { ?>
      //need an argument here to say display pages on the same level as current page
    
      <?php } ?>

    Hopefully that make sense, I've tried a few methods but just can't seem to get both arguments firing correctly.

  2. Shane G
    Member
    Posted 5 years ago #

  3. mitchrenton
    Member
    Posted 5 years ago #

    Thanks for that, are you suggesting I use 2 different page templates?

    I'm really trying to keep this as lightweight as possible and would much prefer to use one template.

    Any other suggestions?

  4. mitchrenton
    Member
    Posted 5 years ago #

    I don't think I explained myself well enough in my original post. My page hierarchy is like this...

    About -> James
    Tim
    David

    So If I am on the about page I want to display, James, Tim and David. If I am on either the James, Tim or David page still want to display the same pages (James, Tim, David).

    Just wondered if I am on the right track with this code...

    <?php
      $children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0');
      if ($children) { ?>
      <ul>
      <?php echo $children; ?>
      </ul>
      <?php } else; { ?>
      //need an argument here to say display pages on the same level as current page
    
      <?php } ?>

Topic Closed

This topic has been closed to new replies.

About this Topic