• Hi,
    I was wondering if someone could show me how to display sub-pages from parent page.

    at “parent page” -> “child” -> “sub-pages”

    basically listing of two level down without including any of the parent page or child page.

    each of the child page contain several sub-pages and I want to list them all.

    thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    if you know the ID of the “child” page you can do

    <ul>
      <?php wp_list_pages('child_of=10'); ?>
    </ul>

    or in a variable

    <ul>
      <?php wp_list_pages('child_of=' . $pageID ); ?>
    </ul>

    Thread Starter radiofranky

    (@radiofranky)

    Hi,
    thanks for your reply. But that was my real question.
    How do you do dynamically in the template retrieve two level down and nothing else. ??

    Moderator keesiemeijer

    (@keesiemeijer)

    put this in your theme’s functions.php

    function getSubPages() {
    $my_pages = get_pages();
    $subpages = '';
    if(!empty($my_pages)){
    
      foreach ($my_pages as $pagg) { // loop pages
        if($pagg->post_parent != 0){
        $parent = get_page($pagg->post_parent);
      		if($parent->post_parent != 0){
          $subpages .= $pagg->ID . ",";
          }
        }
      }
    wp_list_pages('include='.$subpages);
    }
    }

    And put this somewere in your template files:
    <?php getSubPages(); ?>
    This will show a list of all your sub-pages

    nice function buddy

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘listing subpages only from parent page’ is closed to new replies.