Title: Random Posts Changes Single Thumbnail?
Last modified: August 30, 2016

---

# Random Posts Changes Single Thumbnail?

 *  [thelackof](https://wordpress.org/support/users/thelackof/)
 * (@thelackof)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/random-posts-changes-single-thumbnail/)
 * Recently I changed my code around. The “random posts” script I have been using
   for some years, I guess I for the first time put in a leftbar, loading before
   the single thumbnail.
 * The last image to load in the random posts is being loaded in full size, even
   though the random posts is loading a resized/cropped version.
 * Here is the code:
 *     ```
       <div class='random'>
       <div class='contain'>
   
       <?php $tabs = get_option('nt_tabs'); if ($tabs) { ?><?php } else {?>
       <div class="tabs">
   
       <div class="panes"> 
   
       <div>
       <ul>
       <?php
       $args = array( 'numberposts' => 4, 'orderby' => 'rand' );
       $rand_posts = get_posts( $args );
       foreach( $rand_posts as $post ) : ?>
   
       <li>
   
       <a href="<?php the_permalink(); ?>" rel="bookmark" title='<?php the_title(); ?>'>
       <?php the_post_thumbnail( '250-180' ); ?>
       <?php the_title(); ?>
       </a>
   
       </li>
   
       <?php endforeach; ?>
       </ul>
       </div>
   
       </div><!-- panes -->
       </div><!-- tabs -->
   
       <?php } ?>
   
       </div><!-- contain -->
       </div><!-- random -->
       ```
   

Viewing 1 replies (of 1 total)

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/random-posts-changes-single-thumbnail/#post-6389327)
 * try to add `wp_reset_postdata()` to the end of your code;
    [https://codex.wordpress.org/Function_Reference/wp_reset_postdata](https://codex.wordpress.org/Function_Reference/wp_reset_postdata)

Viewing 1 replies (of 1 total)

The topic ‘Random Posts Changes Single Thumbnail?’ is closed to new replies.

## Tags

 * [single](https://wordpress.org/support/topic-tag/single/)
 * [thumbnail](https://wordpress.org/support/topic-tag/thumbnail/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [Michael](https://wordpress.org/support/users/alchymyth/)
 * Last activity: [10 years, 10 months ago](https://wordpress.org/support/topic/random-posts-changes-single-thumbnail/#post-6389327)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
