【问题标题】:If condition for wordpress multiple featured image plugin如果 wordpress 多特色图片插件的条件
【发布时间】:2018-07-31 18:45:31
【问题描述】:

我已经设置了多个特色图片插件。这对我来说很好。

我的要求是:

if: The Multiple Post Thumbnail Exists
    then: Show the Multiple Post Thumbnail Image
else: Show the Default Featured Image Thumbnail

现在我使用以下代码显示了多个特色图片:

<?php add_image_size('post-big-artful-interiorsimg-fullsize', full);
        if (class_exists('MultiPostThumbnails')) : MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'big-artful-interiors', NULL, 'post-big-artful-interiorsimg-fullsize'); 
        endif; 
?>

并使用以下代码显示默认特色图片:

<?php the_post_thumbnail('thevoux-single',array('itemprop'=>'image')); ?>

所以请帮助我,如果多个特色图片不可用,我该如何显示默认特色图片。有什么想法可以告诉我。

谢谢。

【问题讨论】:

  • 试试这个 'image')); } ?>
  • 能否请您格式化代码并重新发送。谢谢。
  • 这对你有用吗?然后我会添加答案!
  • 我只喜欢格式化代码。所以首先请格式化代码然后我会测试。
  • 试试下面的代码,如果它有效,请告诉我

标签: wordpress image post dynamic-featured-image


【解决方案1】:

试试这个代码

<?php if (class_exists('MultiPostThumbnails') && MultiPostThumbnails::has_post_thumbnail('post', 'big-artful-interiors')) {

add_image_size('post-big-artful-interiorsimg-fullsize', full);
                        MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'big-artful-interiors', NULL, 'post-big-artful-interiorsimg-fullsize');

} else {
    the_post_thumbnail('thevoux-single',array('itemprop'=>'image'));    
} ?>

【讨论】:

  • 不,那不行。如果 MultiPostThumbnails 图像不可用,则无法显示默认特色图像。
  • 使用你的代码,我已经应用了我的逻辑,如果条件很好。谢谢。
猜你喜欢
  • 2012-12-12
  • 2022-10-20
  • 1970-01-01
  • 2014-05-13
  • 1970-01-01
  • 1970-01-01
  • 2019-07-31
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多