 <p><a href="https://developer.wordpress.org/reference/functions/has_post_thumbnail/" rel="nofollow"><code>has_post_thumbnail()</code></a> takes an optional parameter of <code>$post</code>, which can be a post ID or a WP_Post object.</p> <p>The default is the global <code>$post</code> object. You need to pass the post ID to tell WordPress to check the recent post in your loop instead of the global <code>$post</code> object. Like this:</p> <pre><code>if ( has_post_thumbnail( $recent['ID'] ) ) { $photo = get_the_post_thumbnail( $recent['ID'], 'large' ); echo '&lt;div class="section1-2singlephoto"&gt;' . $photo . '&lt;/div&gt;'; } else { echo 'no Thumbnail'; } </code></pre>