Support » Fixing WordPress » Random Child Page

  • I’m trying to display a random child page’s content. Not sure how to go about it. So far I’m using the following code to display 2 child page’s content but I want these 2 to be random not the latest 2.

    <?php
    					$mypages = get_pages( array( 'child_of' => 48	, 'sort_column' => 'post_date', 'sort_order' => 'desc', ) );
    					foreach( $mypages as $page ) {
    						$content = $page->post_content;
    						$content = apply_filters( 'the_content', $content );
    						$count++;
    					    if ( $count < 3 ) {  // only process 3 ?>
    							<?php echo $content; ?>
    					<?php
    					}
    				}
    				?>

    thanks

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Random Child Page’ is closed to new replies.