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 have this working for the most part, but some of the syntax is wrong someplace because when the post DOESNT have a thumbnail, it still prints that last echo and closes a div outside of the conditional. Can someone help me get this syntax on this code right? Basically I want: Check for venue image, if it's there, display it. If there IS a thumbnail image, then check for a custom field, if it's there, display it. If not, do nothing, if no venue image, do nothing. Here is my code:

<?php 
if ( has_post_thumbnail() ) 
echo '<div id="venue-single-img">';
{ // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail();
if ( get_post_meta($post->ID, 'Venue Image Notation', true) ) {
echo '<span>' . get_post_meta($post->ID, 'Venue Image Notation', true) . '</span>'; }
else {}
echo '</div>';
}
?>
share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

I believe this should do what you want:

<?php
if ( has_post_thumbnail() ) {
    echo '<div id="venue-single-img">';
    the_post_thumbnail();
    if ( get_post_meta($post->ID, 'Venue Image Notation', true) ) {
        echo '<span>' . get_post_meta($post->ID, 'Venue Image Notation', true) . '</span>';
    }
    echo '</div>';
}
?>
share|improve this answer
    
yes! that's perfect. thank you. –  jamie Aug 31 '12 at 15:44
    
Great to hear! If my answer helped you, please consider marking it as accepted (the check-mark). Thanks! –  Zach Aug 31 '12 at 16:08
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.