Ok, the code below works. I've crated a custom field for scores from Rotten Tomatoes that I can add to my Blu-Ray reviews. Based on its score (above 60 will get a "fresh" rating, below a "rotten") it'll display the appropriate image.
This works fine.
But...it also displays on every page; even those without scores assigned yet.
<?php
global $wp_query;
$postid = $wp_query->post->ID;
$result = ( get_post_meta($postid, 'ecpt_tomatometer', true));
if ($result >= 60) {
echo '<img src="/images/misc/fresh.png" width="102" height="25"> <span class=tomatometer>' . get_post_meta($postid, 'ecpt_tomatometer', true) . '%</span><br />';
}
else {
echo '<img src="/images/misc/rotten.png" width="102" height="25"> <span class=tomatometer>' . get_post_meta($postid, 'ecpt_tomatometer', true) . '%</span><br />';
}
?>
Now below is another snippet of code that works, yet I can't seem to intertwine the two. This (below) basically says "if there's something in the custom field, then display the code (above), otherwise don't display anything.
So I've got both parts of what I want to work, but I can't seem to get them to work together.
<?php
global $wp_query;
$postid = $wp_query->post->ID;
if( get_post_meta($postid, 'tomatometer', true))
{ ?>
This won't show up if there's nothing in the field.
<?php }
elseif( get_post_meta($postid, 'ecpt_tomatometer', true)) {
?>
this will display all of the information I need it to.
<?php } ?>
Ideas?