2012-09-23 62 views
0

我使用下面的代碼上的twentyelevenWordPress的郵政縮略圖問題(僅1縮略圖上頭版)

get_header(); ?> 

    <div id="primary"> 
     <div id="content" role="main"> 

     <?php if (have_posts()) : ?> 

      <?php twentyeleven_content_nav('nav-above'); ?> 

      <?php query_posts('cat=4&amp;showposts='.get_option('posts_per_page')); ?> 

      <?php /* Start the Loop */ ?> 
      <?php while (have_posts()) : the_post(); ?> 
      <div class="post-thumb-title"> 
      <a href="<?php the_permalink() ?>"><?php the_post_thumbnail(array(632,305));?></a> 
      <p class="thumb-title"><?php the_title(); ?></p> 
      </div>     

      <?php endwhile; ?> 

      <?php twentyeleven_content_nav('nav-below'); ?> 

     <?php else : ?> 

      <article id="post-0" class="post no-results not-found"> 
       <header class="entry-header"> 
        <h1 class="entry-title"><?php _e('Nothing Found', 'twentyeleven'); ?></h1> 
       </header><!-- .entry-header --> 

       <div class="entry-content"> 
        <p><?php _e('Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'twentyeleven'); ?></p> 
        <?php get_search_form(); ?> 
       </div><!-- .entry-content --> 
      </article><!-- #post-0 --> 

     <?php endif; ?> 

     </div><!-- #content --> 
    </div><!-- #primary --> 

<?php get_sidebar(); ?> 
<?php get_footer(); ?> 

index.php文件正如你可以從上面的代碼中看到,我只顯示了Cat ID = 4的帖子,我使用css將標題疊加在使用自定義大小的函數「the_post_thumbnail」生成的圖像縮略圖上。 問題是,首頁僅顯示第一篇文章的帖子和縮略圖的標題。

您可以在這裏看到的網站:http://fusion.fusionconstruction.co.uk/

鏈接到其他職位類別爲ID 4選擇:

http://fusion.fusionconstruction.co.uk/fusion-media-at-revolution-round-1/

http://fusion.fusionconstruction.co.uk/fusion-launch-new-website-for-dean-downing/

我想顯示所有類似的帖子第一個。

謝謝!

+0

對不起,我很困惑發生了什麼,沒有發生。我只在第一個鏈接中看到1個帖子,其他2個鏈接看起來相同。什麼是對的,什麼是錯的? – zenkaty

+0

啊,等等,好吧,第一個鏈接應該有3張圖片呢?前兩個鏈接是空的,是嗎?那些文章是否有精選圖片,或者是插入到網頁中的圖片? – zenkaty

+0

@zenkaty - 是的,你說得對。這只是所有帖子上的插入圖片。沒有顯示。 –

回答

1
<?php query_posts('cat=4&amp;showposts='.get_option('posts_per_page')); ?> 

大概應該是

<?php query_posts('cat=4&showposts='.get_option('posts_per_page')); ?> 

也就是說,你不應該進行urlencode的符號。希望這是搞亂你的查詢。

此外,the_post_thumbnail()將顯示帖子的精選圖片,因此爲了製作縮略圖,您需要確保所有帖子都有精選圖片。

+0

啊!我沒有注意到我在第一篇文章中設置了精選圖片。只是在所有帖子上添加精選圖片,並且像魅力一樣工作。非常感謝你的幫助。 :) –

+0

該文章是否有圖片?他們需要爲the_post_thumbnail()工作。 –