如何将 post link 添加到 wordpress 中的缩略图?

How to add post link to thumbnail in wordpress?

我在 index.php 中使用以下循环来显示带有缩略图的 post:

<main id="main">
            
                <?php 
                // the query
                $args = array('posts_per_page' => 10 );
                $the_query = new WP_Query( $args ); 
            
                ?>
            
                <?php if ( $the_query->have_posts() ) { ?>
            
                    <!-- loop -->
            
                    <?php while ( $the_query->have_posts() ) {
                     
                                $the_query->the_post(); ?>
           <article id="post"> 
                  
                        <div id="thumbnail">
                        
                            <?php
                            if ( has_post_thumbnail() ) { ?>
                                 <?php the_post_thumbnail(); } ?>
                    
                    </div>
                   
                   <h2><a href="<?php the_permalink();?>"><?php the_title(); ?></a></h2>
                   
                   <div class="entry">
                   
                        <?php the_excerpt(); ?>
                        
                   </div>
                 
           
           </article>
           
 
    
                <?php } } else { ?>
                <p><?php _e( 'Die Posts entsprechen nicht den Kriterien.' ); ?></p>
                <?php }  ?>
       
               <!-- end of the loop -->
 
    
               <?php wp_reset_postdata(); ?>
        </main>
    

如何向缩略图添加永久链接?当用户点击它时,他应该被引导到 post。目前,什么都没有发生。

感谢您的回答。

编辑:我添加了整个循环,因为 Deepti 的回答产生了错误。也许有人可以帮助我。

<?php if ( has_post_thumbnail() ) : ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
    <?php the_post_thumbnail(); ?>
</a>
<?php endif; ?>