WordPress.org

Ready to get started?Download WordPress

Forums

wp-list-page to list only subpages of one particular page (2 posts)

  1. Jeremy Herve
    Member
    Posted 4 years ago #

    Hi!

    I have got an issue building up my navigation menu: I'd like to have a menu listing only subpages of one particular page, and also display the children pages of all pages I display.

    <?php wp_list_pages( 'title_li=&include=484,486,488,490,492,494,496' ); ?>

    I managed to have them displayed by using the include arg, that was easy, but then I dont manage to have the children of these pages to show up.

    Would any of you have an idea about how to do that?
    If my question is not clear enough, do not hesitate to ask for more details, I will try to explain again!

    Thanks!

  2. Jeremy Herve
    Member
    Posted 4 years ago #

    I keep looking around, and this code seems to be like the beginning of something... will try to understand it, but if somebody could help, I'd be gratful! :)

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

Topic Closed

This topic has been closed to new replies.

About this Topic