Php 如果没有缩略图,则忽略缩略图空间

Php 如果没有缩略图,则忽略缩略图空间,php,wordpress,Php,Wordpress,因此,我有下面的代码,可以循环浏览我的文章,并以列表格式显示文章。以下是我正在使用的代码: <?php while (have_posts()) : the_post(); ?> <div class="one-sixth first"><?php the_post_thumbnail(); ?></div> <div class="five-sixths"><a href="<?php the_permal

因此,我有下面的代码,可以循环浏览我的文章,并以列表格式显示文章。以下是我正在使用的代码:

<?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; ?>

这是带有缩略图的图像:

当没有可用的帖子缩略图时,只会留下一个空白:

如果已显示,则检查缩略图,否则显示占位符图像。希望这对你有帮助

<?php
// Must be inside a loop.

if ( has_post_thumbnail() ) {
    the_post_thumbnail();
}
else {
    echo '<img src="' . get_bloginfo( 'stylesheet_directory' ) 
        . '/images/placeholder.jpg" />';
}
?>


你能为“.one-sixth{width:200px}”设置宽度吗谢谢你!/images/目录是post_附件目录吗?不,images/中的主题文件夹就像一个接受魅力的答案。