2013-01-22 40 views
3

我是WordPress新手,在檔案頁面上使用BlankSlate廣告模板我想顯示插入到帖子中的圖像的縮略圖,我該怎麼做?這是我的archives.php代碼。將縮略圖添加到檔案頁面

在此先感謝!

<?php the_post(); ?> 
<?php if (is_day()) : ?> 
<h1 class="page-title"><?php printf(__('Daily Archives: %s', 'blankslate'), '<span>' . get_the_time(get_option('date_format')) . '</span>') ?></h1> 
<?php elseif (is_month()) : ?> 
<h1 class="page-title"><?php printf(__('Monthly Archives: %s', 'blankslate'), '<span>' . get_the_time('F Y') . '</span>') ?></h1> 
<?php elseif (is_year()) : ?> 
<h1 class="page-title"><?php printf(__('Yearly Archives: %s', 'blankslate'), '<span>' . get_the_time('Y') . '</span>') ?></h1> 
<?php elseif (isset($_GET['paged']) && !empty($_GET['paged'])) : ?> 
<h1 class="page-title"><?php _e('Blog Archives', 'blankslate'); ?></h1> 
<?php endif; ?> 
<?php rewind_posts(); ?> 
<?php while (have_posts()) : the_post(); ?> 
<?php get_template_part('entry'); ?> 
<?php endwhile; ?> 
+0

這取決於你想要的縮略圖顯示出來。您可能需要編輯entry.php。儘管無論哪種方式,你都可能需要使用'the_post_thumbnail()'和'has_post_thumbnail()' – Jrod

回答

0

把這段代碼放到你想要它出現的循環中。

<?php if(has_post_thumbnail()) { the_post_thumbnail(); }?>

documentation

顯示特色圖片(以前稱爲郵政縮略圖)爲 目前的職位,如在該職位的編輯畫面設置。

該標籤必須在循環中使用。使用get_the_post_thumbnail($ ID, $大小,$ attr)使用,而不是獲得功能圖像任何職務。

要啓用後縮略圖,當前主題必須包括 add_theme_support(「後縮略圖」);在其functions.php文件中。請參閱 也發佈縮略圖。