如何隐藏某些帖子中的精选图片

Bry*_*Guy 1 wordpress

有没有办法隐藏某些帖子中的精选图片?

我的博客是cur-mudg-eon.com,如果你看一下标题为"孔子说......"的最新帖子(在主页上),你会看到我使用了特色图片并显示了一些摘录文字.当你点击标题或图片时,它会带你到显示我想要显示的漫画的帖子,以及我想隐藏/删除的特色图片.

我只想在某些帖子上这样做,但我希望能够在主页上保留特色图片.

这可能吗?

编辑:

根据要求粘贴文件.

基于Chris Herberts回答我将在哪里将他的代码添加到我的single.php文件中找到的代码中:

    <?php if(has_post_thumbnail()) {
        echo '<figure class="featured-thumbnail"><span class="img-wrap">'; the_post_thumbnail(); echo '</span></figure>';
        }
      ?>
    <?php } else { ?>
      <?php if(has_post_thumbnail()) {
        echo '<figure class="featured-thumbnail large"><span class="img-wrap"><span class="f-thumb-wrap">'; the_post_thumbnail('post-thumbnail-xl'); echo '</span></span></figure>';
        }
      ?>
    <?php } ?> 
Run Code Online (Sandbox Code Playgroud)

Chr*_*ert 7

另一种不依赖于它们的方法是使用自定义字段.

您可以为要隐藏特色图像的帖子设置自定义字段 - 在下图中我分别使用"hide_featured_image"和"yes"作为键和值.

在此输入图像描述

然后,当调用调用函数显示特色图像时,您将检查"hide_featured_image"字段是否设置为"yes".这是一个例子:

$shouldHideFeaturedImage = get_post_meta($post->ID, 'hide_featured_image', true);

if ( $shouldHideFeaturedImage != 'yes' ) {
 if ( has_post_thumbnail() ) {
    the_post_thumbnail('medium'); 
    } 
}
Run Code Online (Sandbox Code Playgroud)