Hi all,
Hoping you can help. I've built a book-catalog plugin which uses custom metadata fields. Right now I'm building the template that displays the custom metadata and my conditional statements always return true, even if they are empty. (My html tags are echoing even though the custom field is empty)
<?php
if ( get_post_meta( $post->ID, 'book-excerpt' ) != null ); {
echo '<div id="book-excerpt">';
echo '<h6>Excerpt from <em>'; echo get_post_meta($post->ID, 'book-title', true); echo '</em></h6>';
echo get_post_meta($post->ID, 'book-excerpt', true);
echo '</div>';
}
if ( get_post_meta( $post->ID, 'book-blurb-1' ) != null ); {
echo '<div id="blurbs">';
echo '<h6>What’s being said about <em>';
echo get_post_meta($post->ID, 'book-title', true);
echo '</em></h6>';
echo '<div class="blurb">';
echo get_post_meta($post->ID, 'book-blurb-1', true);
echo '</div>';
}
if ( get_post_meta( $post->ID, 'book-blurb-2' ) != null ); {
echo '<div class="blurb">';
echo get_post_meta($post->ID, 'book-blurb-2', true);
echo '</div>';
}
if ( get_post_meta( $post->ID, 'book-blurb-3' ) != null); {
echo '<div class="blurb">';
echo get_post_meta($post->ID, 'book-blurb-3', true);
echo '</div>';
}
if ( get_post_meta( $post->ID, 'book-blurb-1' ) != null); {
echo '</div>'; // closes the div links-extras without needing all three blurbs
}
if ( get_post_meta( $post->ID, 'author-photo-bio' ) != null); {
echo '<div id="author-photo-bio">';
echo '<h6>About the Author</h6>';
echo get_post_meta($post->ID, 'author-photo-bio', true);
echo '</div>';
}
?>