WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using this code

        $children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0');
        $subpages = ($post->post_parent) ? wp_list_pages('title_li=&child_of='.$post->post_parent.'&echo=0') : wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0') ; 
            if ($children) { ?>
               <li><?php echo $children; ?></li>
            <?php } else { ?>
               <?php echo $subpages; ?> 
    <?php } ?>

This code display child pages on a parent page, also if there are not childs it will display the child of the parent (brothers).

However I need to restrict it to display only 5 pages, something like showpost=5 for post, I havent been able to do it, any help???

share|improve this question
up vote 0 down vote accepted

Just pass number=5 and it should work since wp_list_pages() uses get_pages() which has number parameter, and also if you look at wp_list_pages codex entry at the bottom under change log you can see that it take the number parameter since version 2.8

share|improve this answer
worked great! thx a lot! – andresmijares25 Oct 13 '11 at 3:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.