0
我使用下面的循環在我的index.php以顯示與縮略圖的帖子:如何在wordpress中添加文章鏈接到縮略圖?
<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>
\t
<?php } } else { ?>
<p><?php _e('Die Posts entsprechen nicht den Kriterien.'); ?></p>
<?php } ?>
\t \t \t
<!-- end of the loop -->
\t
<?php wp_reset_postdata(); ?>
</main>
我如何添加一個固定鏈接縮略圖?當用戶點擊它時,他應該被引導到該帖子。目前,沒有任何事情發生。
感謝您的回答。
編輯:我添加了整個循環,因爲Deepti的答案會產生錯誤。也許有人可以幫助我。
謝謝您的回答。我更新了我的帖子,因爲它產生了一個錯誤。你能幫我解決嗎? –
試試這個,我錯過了結尾,如果 –
哇,謝謝。它像一個魅力 –