WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Parent/child/grandchild page conundrum

[Resolved] Parent/child/grandchild page conundrum

  • Ok, here we go! I have a page hierarchy with 6 levels (6 ul tags). In the sidebar it looks something like this:

    • 1
    • 2
      • 2.1
      • 2.2
        • 2.2.1
        • 2.2.2
          • 2.2.2.1
          • 2.2.2.2
            • 2.2.2.2.1
            • 2.2.2.2.2
            • 2.2.2.2.3
              • 2.2.2.2.3.1
      • 2.3
    • 3

    Which may look pretty messy, but it all makes sense on the live site which you can see here.

    At the moment I’m using the following code to show parent pages when on a child page:

    <ul>
    <?php $output = wp_list_pages('echo=0&depth=0&title_li=' );
    			  if (is_page( )) { $page = $post->ID;
    			  if ($post->post_parent) { $page = $post->post_parent; }
    
    			  $children=wp_list_pages( 'echo=0&child_of='.$post->post_parent.'&title_li=&depth=0' );
    
    			  if ($children) { $output = wp_list_pages ('echo=0&child_of='.$post->ID.'&title_li=&depth=0'); } } echo $output; ?>
    </ul>

    Which works, but I need to tweak it a bit. If you go here you can see all the child pages in the left sidebar, but if you click on one of those child pages, I want it to still show the same links.

  • The topic ‘[Resolved] Parent/child/grandchild page conundrum’ is closed to new replies.
Skip to toolbar