WordPress Loop with content

<?php 
if ( have_posts() ) {
    while ( have_posts() ) {
        the_post(); 
        ?>
        <!-- Set link around thumbnail -->
        <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
        <!-- Show the title -->
        <h2><?php the_title(); ?></h2>
        <!-- Show the excerpt -->
        <div><?php the_excerpt();?></div>
        <?php
    } // end while
} else {
    esc_html_e( 'Sorry, no posts to show.' );
}
?>