• I need to create a custom wp_list_pages code, that isn’t on the codex.

    Basically, I’m starting with this:

    Page List that: Only displays if child (sub) pages exist, displays page list of subpages on the parent page AND on the child pages HOWEVER this code keeps the parent page name in the title which makes it different from the previous example. (used for navigation on http://allianceitpro.com/)
    <?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);
      }
    
      else {
      $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
      $titlenamer = get_the_title($post->ID);
      }
      if ($children) { ?>
    
      <h2> <? echo $titlenamer ?> </h2>
      <ul>
      <?php echo $children; ?>
      </ul>
    
    <?php } ?>

    What i need is pretty close to the above but I need the titlenamer to change if you’re on a Child page that has children of it’s own. I hope this makes sense.

    I need a page that does the following:

    When visiting a top level page with children, just the children pages and no descendant pages are listed

    example:

    <h2> <? echo $titlenamer ?> THIS IS THE PARENT PAGE TITLE </h2>
      <ul>
      <?php echo $children; ?>
      </ul>

    When visiting a child of a top level page with no children then menu would look like the above ( ala list subpages even if on a subpage )
    example:

    <h2> <? echo $titlenamer ?> THIS IS THE PARENT PAGE TITLE </h2>
      <ul>
      <?php echo $children; ?> ALL CHILDREN (but NO descendants of children)
      </ul>

    When visiting a child page that HAS descendants/children, just the children (of that child page) is listed.

    example:

    <h2> <? echo $titlenamer ?> THIS IS THE [top-level] CHILD PAGE TITLE </h2>
      <ul>
      <?php echo $children; ?> this is the list for the descendents of child page above
      </ul>

    if you need a live example go to webcti .com and click solutions page.
    take note of the left side menu and Then click security and see how the menu changed ….

Viewing 1 replies (of 1 total)
  • Thread Starter Mr. Bigsby

    (@holgria)

    Basically I need PARENT and Children listed unless you’re on a Child page with subpages /children of it’s own these would display CHILD and it’s a subpages/children.

    The menu would always only be 2 levels.

    I feel like I’m getting lost in the semantics of this, which is why I provided the link to a website that makes this happen.

Viewing 1 replies (of 1 total)
  • The topic ‘Custom WP_LIST_PAGES – Help?’ is closed to new replies.