Display “get_pages” Array in Random Order?
-
Hello everyone.
I’ve written the code below to pull three testimonials from the portfolio section of a site and display them on the home page. Everything is working fine, except I can’t seem to get them to display in a random order.
Is there a way to do this using “get_pages”, or am I stuck always showing them in a specific order?
Here’s the code:
<?php $pages = get_pages(array('child_of' => 15, 'meta_key' => 'testimonial', 'number' => 3)); foreach($pages as $child) { $testimonial = get_post_meta($child->ID, 'testimonial', false); $projName = get_the_title($child->ID); $projLink = get_permalink($child->ID); if ($testimonial) { foreach ($testimonial as $testimony) { $fullValue = explode("|", $testimony); $docPic = $fullValue[0]; $docQuote = $fullValue[1]; $docName = $fullValue[2]; ?> <li class="testimonial"> <img src="<?php echo $docPic; ?>" alt="<?php echo $docName; ?>" title="<?php echo $docName; ?>" /> <p class="quote">“<?php echo $docQuote; ?>”</p> <p class="cite"><span class="doc"><?php echo $docName; ?></span> | <a href="<?php echo $projLink; ?>" title="<?php echo $projName; ?>"><?php echo $projName; ?></a></p> </li><!-- /.testimonial --> <?php } } } ?>Thanks for whatever help you can provide! 🙂
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
The topic ‘Display “get_pages” Array in Random Order?’ is closed to new replies.