How do I hide an empty custom field?
-
I know this can be done because I manged it on an old blog I used to have, but stupidly I deleted all the theme files and I can’t remember how to do this anymore.
What I want to do is link to other websites from my blog posts using custom fields. I also want each link to display as an image that will be in my “uploads” folder.
Not every post will need to link to an outside website so I don’t want the link image to be present on posts that I don’t have any links on.
So far I’m having no luck hiding the image on posts with no links. Any help would be greatly appreciated.
At the minute I’m using this code…
<a href="<?php $key="CUSTOM FIELD"; echo get_post_meta($post->ID, $key, true); ?>"><img class="aff" src="IMAGE LOCATION" /></a>
but the image shows up on every post, link or no link.
Thanks in advance
- The topic ‘How do I hide an empty custom field?’ is closed to new replies.