• 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)
Viewing 1 replies (of 1 total)

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