Support » Themes and Templates » How do you show a menu of pages listing subpages of the current parent page

  • Hi

    I’m wondering, is there a good “wordpress-way” to list all parent or “root” pages in a sidebar, and if you are on a child-page of something also display this page and all its siblings in the menu as well – but only those, not all subpages there are? Ahh confusing. What I mean ist, you know these typical 1999-Portal-Sites that have a menu on the left showing you on which page you are right now in such a manner:

    Section 1
    Section 2
    ….SubSection2
    ….SubSection2
    ….SubSection2 (where you’re on right now)
    ….SubSection2
    Section 3
    Section 4

    hope that’s not too confusing.

    Luke

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hey man,

    I think <?php wp_list_pages('depth=0&amp;title_li='); ?>

    IS what your looking for, replace <?php wp_list_pages('&amp;title_li='); ?>

    With what i mentioned, make a backup first tho incase im wrong!

    Thread Starter luke-23ae

    (@luke-23ae)

    That shows all subpages of all the pages. I only want to see subpages of the page I’m viewing at the moment. Or, if I am on a subpage, I want to see all the subpages of the parent-page, while all the subpages of all other pages won’t show.

    Try this:

    <?php
    	global $post;
    	if ( $post->post_parent )
    		echo '<ul>' . wp_list_pages( array( 'title_li' => false, 'child_of' => $post->post_parent, 'echo' => 0 ) ) . '</ul>';
    	else
    		echo '<ul>' . wp_list_pages( array( 'title_li' => false, 'child_of' => $post->ID, 'echo' => 0 ) ) . '</ul>';
    ?>
    Thread Starter luke-23ae

    (@luke-23ae)

    Well, thanks a lot, that is a step further, but it only shows the submenus – I also want to show the rest of the menu, you know like in that classic homepage-style showing all root-level elements and showing the submenus to the page you are at the moment. Like

    -Parentpage 1
    -Parentpage 2
    -Parentpage 3
    --Subpage 1
    --Subpage 2
    ---SubSubpage 1
    ---SubSubpage 2 (active page)
    --Subpage 3
    -Parentpage 4
    -Parentpage 5
    -Parentpage 6

    You know, that the other pages also have subpages, but just won’t show until you are on that page or on one of it’s children.

    PS: Is there maybe a good plugin for this?

    There is a great simple plugin for this:

    http://wordpress.org/extend/plugins/hierarchical-pages/

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How do you show a menu of pages listing subpages of the current parent page’ is closed to new replies.