我已经设置了多个精选图片插件。这对我有好处。
我的要求是:
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')); ?>
所以请帮助我如果没有多个特色图像,我怎么能显示默认的特色图像。任何想法然后通知我。
感谢。
答案 0 :(得分: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'));
} ?>