I currently have a custom field for rating the post’s importance. In index.php template I call an image (named by number) based on the rating entered in the custom field:
<img src="<?php bloginfo('url'); ?>/images/peppers/<?php $values = get_post_custom_values("peppers"); echo $values; ?>.gif">
Works fine except when there is no rating value entered for the post. Then I get the red x img placeholder
How do I make this conditional – that is so it shows the img only if custom field key “peppers” has an assigned value? If no value (empty), nothing is placed there.
- The topic ‘display custom field only if value present?’ is closed to new replies.