Add the meta_key parameter to fetch the latest posts which have featured image set. $args = array( 'numberposts' => '10', 'meta_key' => '_thumbnail_id' );
<?php
/*
Template Name: Recent Profiles
*/
get_header();
?>
<h1 class="page-title"><?php the_title(); ?></h1>
<div id="content">
<div id="masonry">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div class="item normal" data-order="1"><!--BEGIN .item -->
<div <?php post_class(); ?> id="featured-<?php the_ID(); ?>"><!--BEGIN .hentry -->
<?php
$args = array( 'numberposts' => '10', 'meta_key' => '_thumbnail_id' );
$recent_posts = wp_get_recent_posts( $args );
foreach ( $recent_posts as $recent ) {
if ( has_post_thumbnail( $recent["ID"] ) ) {
echo '<a href="' . get_permalink( $recent["ID"] ) . '">';
echo get_the_post_thumbnail( $recent["ID"], 'archive_grid' );
echo '</a>';
}
}
?>
</div>
<!--END .hentry-->
</div><!--END .item -->
<?php endwhile; endif; ?>
<?php get_template_part( 'includes/index-loadmore' ); ?>
</div>
<!--END #masonry -->
<div id="masonry-new"></div>
<!--BEGIN .post-navigation -->
<div class="post-navigation clearfix">
<?php dt_pagination(); ?>
<!--END .post-navigation -->
</div>
</div><!-- #content -->
<?php get_footer(); ?>