Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am using built-in Wordpress function to add (small) thumbnails to each post. In addition to the post thumbnail I am using MultiPostThumbnail plugin to add custom category (large) image.

Since not all posts have thumbnails or "secondary image" (as it is called by MultiPostThumbnail plugin) I would like to display thumbnails (either large or small) in this order:

  1. If I a post has large (MultiPostThumbnails) thumbnail and (small) thumbnail display only (large) thumbnail.

  2. If a post doesn't have a (large) thumbnail display the (small) thumbnail.

I hope now it makes more sense. It's a simple if statement but I can't get it to work. Here is a "pseudo-code".

<?php if (class_exists('MultiPostThumbnails')
   && MultiPostThumbnails::has_post_thumbnail('post', 'secondary-image')) :
      MultiPostThumbnails::the_post_thumbnail('post', 'secondary-image', NULL,  'post-secondary-image-thumbnail');
else {
   the_post_thumbnail();
}
?>
share|improve this question
    
It's not clear what your question is. Does the code you provided not work? Did you write this yourself or did you find it somewhere? –  Jan Fabry Jan 3 '11 at 12:31
    
I added a better description of my problem. The code above is a 'pseudo code'. It doesn't work. –  eeyore Jan 3 '11 at 15:24
    
For me this looks like you're looking for a specific feature of that plugin. Please contact the plugin author and discuss your needs with her/him. –  hakre Jan 4 '11 at 18:23

1 Answer 1

In code you posted you have issue with syntax - you should stick either with braces style or colons style, mixing them is not supported.

if(class_exists('MultiPostThumbnails')
    && MultiPostThumbnails::has_post_thumbnail('post', 'secondary-image')) {

    MultiPostThumbnails::the_post_thumbnail('post', 'secondary-image', NULL, 'post-secondary-image-thumbnail');
} 
else {

    the_post_thumbnail();
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.