Title: Selecting random posts from an array
Last modified: August 20, 2016

---

# Selecting random posts from an array

 *  [boogysi](https://wordpress.org/support/users/boogysi/)
 * (@boogysi)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/selecting-random-posts-from-an-array/)
 * On my blog homepage I’m using a wp query to display 8 featured posts from an 
   array. Now I’m trying to write a script that would randomly pick 3 elements out
   of the first 5 elements of the array and assign them a custom css class (.feat_large)
   and a specific post thumbnail the_post_thumbnail( ‘homepage-thumb-large’ ). Remaining
   5 posts should use the the_post_thumbnail( ‘homepage-thumb-small’ ) and no specific
   css class.
 * I managed to achieve something similar in JS, but now I’d like to have a server-
   side php solution. My knowledge of php is very limited, so I’d appreciate some
   help on this issue.

The topic ‘Selecting random posts from an array’ is closed to new replies.

 * 0 replies
 * 1 participant
 * Last reply from: [boogysi](https://wordpress.org/support/users/boogysi/)
 * Last activity: [13 years, 3 months ago](https://wordpress.org/support/topic/selecting-random-posts-from-an-array/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
