所以我有以下代码循环浏览我的帖子,并以列表格式显示帖子。这是我正在使用的代码:
<?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; ?>
答案 0 :(得分:1)
如果检查缩略图是否已显示,否则显示占位符图像。希望对您有帮助。
<?php
// Must be inside a loop.
if ( has_post_thumbnail() ) {
the_post_thumbnail();
}
else {
echo '<img src="' . get_bloginfo( 'stylesheet_directory' )
. '/images/placeholder.jpg" />';
}
?>