Hi guys wondering if anyone can help. I have this code that lists all sub pages, their featured image and title/link. What I’d like to be able to do is randomize the the size of the featured image between what WordPress offers… small/medium/large?

Any ideas?

    <?php 
    $args = array(
    'parent' => 2,
    'post_type' => 'page',
    'post_status' => 'publish'
    ); 
$pages = get_pages($args);  ?>
<ul> 
<?php
foreach( $pages as $page ) {
?>

 <li>
    <a href="<?php echo  get_permalink($page->ID); ?>" rel="bookmark" title="<?php echo $page->post_title; ?>">
    <div><span class="thumbnail"><?php echo get_the_post_thumbnail($page->ID, 'thumbnail'); ?></span>
    <span class="title"><?php echo $page->post_title; ?></span></div>
    </a>
</li>
<?php
 }  
?>
    </ul>

Read more here: Random Size on Featured Image


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: