I’m using this code
<?php
$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???
Just pass
number=5
and it should work sincewp_list_pages()
usesget_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 thenumber
parameter since version 2.8