• Resolved downfast

    (@downfast)


    From here I get all the sub pages but I would like to only get 1 random subpage instead.

    <ul>
    	<?php $pages =
    	$parent = 6;
    	$args=array(
      	'child_of' => $parent
    	);
    	$pages = get_pages($args);
    	if ($pages) {
      	$pageids = array();
      	foreach ($pages as $page) {
        	$pageids[]= $page->ID;
      	}
        	echo get_the_post_thumbnail($page->ID);
    	}
    	?>
    </ul>

    Help?

Viewing 1 replies (of 1 total)
  • Thread Starter downfast

    (@downfast)

    found it.

    <ul>
    <?php
    $parent = 6;
    $args=array(
    'child_of' => $parent
    );
    $pages = get_pages($args);
    shuffle($pages);
    if ($pages) {
    $pageids = array();
    foreach ($pages as $page) {
    $pageids[]= $page->ID;
    }
    echo get_the_post_thumbnail($page->ID);
    }
    ?>
    </ul>

Viewing 1 replies (of 1 total)
  • The topic ‘How to get a single random sub page?’ is closed to new replies.