Ketan
Ketan

Reputation: 619

If condition for wordpress multiple featured image plugin

I have setup Multiple featured image plugin. That's work good for me.

My requirement is:

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

Right now i have displayed multiple featured image using following code:

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

and default featured image display using following code:

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

How can I show default featured image if Multiple featured image is not available. Any idea then inform me.

Upvotes: 0

Views: 346

Answers (1)

developerme
developerme

Reputation: 1955

Try This code

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

Upvotes: 1

Related Questions