• https://usshyphron.com/cmsdev/deys/?page_id=25

    It displays the subpages of the current parent page, but there are two issues. When you go deeper into a 3rd level page it loses the list of pages. I’d also like it to display the top level parent page at the top of the list.

    This is the code I’m using currently.

    <?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) { ?>
    <li class="sub-nav">
    <ul><?php echo $children; ?></ul>
    </li>
    <?php } ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter John Leschinski

    (@picard102)

    Made some modifications too it. Got it to display the parent page, and apply a current class to it when selected. Not sure if it’s the best way to go about it, but it works.

    Still looking for a solution to the issue of the 3rd level item showing a diffrent menu.

    Any help?

    <?php  if($post->post_parent)
      $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0&depth=2");
      else
      $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0&depth=2");
      if ($children) { ?>
    
    <li class="sub-nav">
    <ul>
    <li class="parent current-<?php echo ($post->post_parent);?> " ><a href="<?php $parent_link = get_permalink($post->post_parent); echo $parent_link;?>">
    <?php $parent_title = get_the_title($post->post_parent); echo $parent_title;?></a></li>
    <li><ul><?php echo $children; ?></ul></li>
    
    </ul></li>
    <?php } ?>

    Any luck figuring it out?

    I’m using:

    <?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) { ?>
    
      <ul>
      	<?php echo $children; ?>
      </ul>
    
    <?php } ?>

    And have the same problem with the 3rd level page not showing the subpage menu.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display Parent, and Sub Pages.’ is closed to new replies.