I set up a loop to call the featured image from 5 posts from a certain category in wordpress.
Without:
$do_not_duplicate = $post->ID;
I got duplication. So this is the code for the loop.
// The Query $the_query = new WP_Query( array ('category__in' => '5','posts_per_page' => '5','orderby' => 'rand') ); $do_not_duplicate = $post->ID; // The Loop while ( $the_query->have_posts() ) : $the_query->the_post(); echo '<li>'; echo '<a href="' . get_permalink( $thumbnail->ID ) . '" title="' . esc_attr( $thumbnail->post_title ) . '">'; echo get_the_post_thumbnail($thumbnail->ID, 'medium'); echo '</a>'; echo '</li>'; endwhile;