因此,我有以下代碼可以循環瀏覽我的帖子并以列表格式顯示帖子。以下是我正在使用的代碼:<?php while (have_posts()) : the_post(); ?>
<div class="one-sixth first"><?php the_post_thumbnail(); ?></div>
<div class="five-sixths"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></div>
<?php endwhile; ?>以下是帶有縮略圖的圖像:這是當沒有帖子縮略圖可用時,它只會留下一個空白區域:
1 回答

jeck貓
TA貢獻1909條經驗 獲得超7個贊
如果選中縮略圖(如果已顯示),則顯示占位符圖像。希望這對你有幫助。
<?php
// Must be inside a loop.
if ( has_post_thumbnail() ) {
the_post_thumbnail();
}
else {
echo '<img src="' . get_bloginfo( 'stylesheet_directory' )
. '/images/placeholder.jpg" />';
}
?>
- 1 回答
- 0 關注
- 72 瀏覽
添加回答
舉報
0/150
提交
取消