2013-06-22 62 views
1

我從添加新帖子部分創建了一個帖子,現在我想檢索它的縮略圖,摘要和標題的帖子。 其他字段按照我想要的方式顯示得很好(標題和摘要),但是無法爲縮略圖檢索到任何內容。下面是我使用的代碼:爲什麼我的文章的縮略圖沒有顯示出來?

<?php 
    $args = array('posts_per_page' => 1, 'order'=> 'DESC','category' => 'watch', 'orderby' => 'post_date','offset' => 1,); 
      $postslist = get_posts($args); 
      foreach ($postslist as $post) : setup_postdata($post); ?> 

      <td class="leftBoxes"> 
       <!--IMAGE- THIS IS the Problem --> 
      <div class="imgMargin"> <?php get_the_post_thumbnail(); ?> </div> 

      <br> 
      <div class="boxScrollsBlogsView"> 
      <h2><?php the_title(); ?> </h2> 
      <P> 
      <?php the_excerpt(); ?> 
      </P> 
      </div> 

      </td> 
      <?php endforeach; ?> 

我加入這行來function.php以及

add_theme_support('post-thumbnails'); 

,我可以看到圖像,當我點擊單發佈視圖,檢查它是否被添加到數據庫。

但它只是不出現在我創建的自定義頁面。

回答

1

我想你應該是echo它作爲函數返回字符串。 EG:

<div class="imgMargin"> <?php echo get_the_post_thumbnail(); ?> </div> 

試試這個:

<div class="imgMargin"> <?php echo get_the_post_thumbnail($post->ID); ?> </div> 
+0

即使當我做迴響在查看源代碼不顯示任何東西弄出來,因爲這: HTTP://oi42.tinypic。 com/ic4gft.jpg – 0bserver07

+0

@Observer嘗試更新的代碼。 – vikingmaster

+0

感謝您的兩次嘗試,但它仍然沒有打印出任何東西!這是否意味着我在使用_Thumbnail_時遇到問題? – 0bserver07

相關問題