I have a site that has Parent and Child pages. I want to be able to show a list of the child pages, listed in Random order. In addition I want to limit the number of child pages shown.
I have found a solution to Listing the pages randomly, however, I need to
1. limit the the number of Child Pages returned
2. Add the Parent Page at the top of the list.
Example:
Parent Page
Child Page
Child Page
Child Page
The Code that I am using is:
add_shortcode( 'wpb_childpages', 'wpb_list_child_pages' );
function wpb_list_child_pages() {
global $post;
if ( is_page() && $post->post_parent ) {
$childpages = wp_list_pages( 'sort_column=rand&title_li=&child_of=' . $post->post_parent . '&echo=0' );
} else {
$childpages = wp_list_pages( 'sort_column=rand&title_li=&child_of=' . $post->ID . '&echo=0' );
}
if ( $childpages ) {
$string = '<ul>' . $childpages . '</ul>';
}
return $string;
}