0

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

我的要求是:

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

因此,如果多个特色图像不可用,请帮助我如何显示默认特色图像。任何想法然后告诉我。

谢谢。

4

1 回答 1

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'));    
} ?>
于 2018-02-21T09:44:56.193 回答