Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

So i found the code below from another question on here, it displays a list of titles from a custom post type, my question is, How do i get the list to randomize?

      <?php
 $queryObject = new WP_Query( 'post_type=announcements&posts_per_page=5' );
 // The Loop!if ($queryObject->have_posts()) {
?>
<ul>
<?php
while ($queryObject->have_posts()) {
    $queryObject->the_post();
    ?>

    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php
}
?>
</ul>
<?php
 }
 ?>
share|improve this question

1 Answer 1

up vote 1 down vote accepted

WP_Query has an orderby property which can be set to rand. If you change your query string to 'post_type=announcements&posts_per_page=5&orderby=rand' you should be good to go. You might want to take the time to read through the whole documentation for WP_Query, just so you're familiar with its capabilities.

share|improve this answer
    
Thank You:) This worked great –  Terrell Anderson Mar 6 '12 at 4:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.