Title: Randomize posts using globalpost
Last modified: August 21, 2016

---

# Randomize posts using globalpost

 *  [magdef](https://wordpress.org/support/users/magdef/)
 * (@magdef)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/randomize-posts-using-globalpost/)
 * I’m trying to randomize the appearance of posts and their thumbnails on my homepage
   by adding orderby=rand in my category.php file. I’m using a child theme of Dessign’s
   Style theme. For some reason the orderby=rand array tag is not working and I 
   don’t understand why.
 * I’m developing locally so cannot post a link.
 * Any help would be greatly appreciated. Thanks!
 * Here is the relevant snippet of code:
 *     ```
       <?php
            global $post;
            $myposts = get_posts( 'orderby=rand&numberposts=7&category_name=Featured Small' );
            foreach($myposts as $post) :
              setup_postdata($post);
            ?>
   
             <div class="small_box">
             <h3 class="bottom_line_title"><a href="<?php the_permalink(); ?>"><?php echo substr(get_the_title(),0,20); ?><?php if(strlen(get_the_title() > 20)) { ?>..<?php } ?></a></h3>
             <?php
             if ( has_post_thumbnail() ) {
               ?> <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('featured-small'); ?></a> <?php
             } else {
               ?> <a href="<?php the_permalink(); ?>"><img src="<?php echo catch_that_image() ?>" /></a> <?php
             }
             ?>
             </div><!--//small_box-->
   
           <?php endforeach; ?>
       ```
   

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/randomize-posts-using-globalpost/#post-3941104)
 * The category.php template is used for category archives. Try adding it to index.
   php.
    [http://codex.wordpress.org/Template_Hierarchy#Home_Page_display](http://codex.wordpress.org/Template_Hierarchy#Home_Page_display)
 *  Thread Starter [magdef](https://wordpress.org/support/users/magdef/)
 * (@magdef)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/randomize-posts-using-globalpost/#post-3941111)
 * What a rookie move. Thanks for the help keesiemeijer. Of course it works now.
 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/randomize-posts-using-globalpost/#post-3941139)
 * No problem. We’ve all done it many a time 🙂

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Randomize posts using globalpost’ is closed to new replies.

## Tags

 * [random posts](https://wordpress.org/support/topic-tag/random-posts/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * Last activity: [12 years, 8 months ago](https://wordpress.org/support/topic/randomize-posts-using-globalpost/#post-3941139)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
