Hiding image if custom field empty
-
Hi.
I am displaying an image on each one of my posts which I load from a custom field. However, not all posts are accompanied by an image and I’d like to not display the image if the custom field is empty, meaning that there is no image to display. This is the code I use to display the image from the custom fields:
<a rel="lightbox[hemingway_block]" href="<?php $values = get_post_custom_values("image07urlLarge"); echo $values[0]; ?>"><img class="imgblock" src="<?php $values = get_post_custom_values("image07urlThumb"); echo $values[0]; ?>" alt="<?php the_title(); ?>" /></a>
What code could I use to hide the image if there is no data in the ‘image07urlLarge’ custom field?
Thanks!
- The topic ‘Hiding image if custom field empty’ is closed to new replies.