Title: Display post images randomly
Last modified: August 21, 2016

---

# Display post images randomly

 *  [mfalber](https://wordpress.org/support/users/mfalber/)
 * (@mfalber)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/display-results-randomly/)
 * Hi friends. First post, hopefully of many —
 * I’m trying to get these images to show up in a random order, I would even be 
   happy if I could get them to show up by date. Right now they only show up with
   the most recent ID displaying first.
 *     ```
       <?php
       		$entry_class = 'show';
       		if ( '' != get_the_post_thumbnail () ) {
       			the_post_thumbnail();
       			$entry_class = 'hide';
       		}
   
       				else {
       			$images = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 999 ) );
       			if ( $images ) {
       				$image = array_shift( $images );
       				$image = wp_get_attachment_image_src( $image->ID, 'mixfolio-featured-thumbnail' );
       				echo '<img src="' . $image[0] . '" class="wp-post-image"/>';
       				$entry_class = 'hide';
       			}
   
       			else {
       				echo '<img src="' . get_stylesheet_directory_uri() . '/images/image.jpg" class="wp-post-image"/>';
       			}
   
       		}
       	?>
       ```
   
 * Originally I tried changing the following:
 * `'orderby' => 'menu_order', 'order' => 'ASC',`
 * but regardless of what options I put in there, it still shows up the same.
 * Any thought?
 * Thanks.

Viewing 1 replies (of 1 total)

 *  [Robin W](https://wordpress.org/support/users/robin-w/)
 * (@robin-w)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/display-results-randomly/#post-4272480)
 * maybe have a look at how these plugins are doing it
 * [http://wordpress.org/plugins/tags/random-image](http://wordpress.org/plugins/tags/random-image)

Viewing 1 replies (of 1 total)

The topic ‘Display post images randomly’ is closed to new replies.

## Tags

 * [array](https://wordpress.org/support/topic-tag/array/)
 * [order](https://wordpress.org/support/topic-tag/order/)
 * [orderby](https://wordpress.org/support/topic-tag/orderby/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [Robin W](https://wordpress.org/support/users/robin-w/)
 * Last activity: [12 years, 8 months ago](https://wordpress.org/support/topic/display-results-randomly/#post-4272480)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
