Hiding if custom field is empty
-
Hi,
I am using custom fields for my posts. For example, I might have a key “Mood” with a value “Happy”. However, I might not want to add my “Mood” field to every post. What code could I use to hide the field from the post if the value for that key is not present? In other words, if I don’t enter anything for a value for the “Mood” key in the custom fields, how can I hide that text from displaying in my post?
This is the code I am using to print the value for that key:
I am feeling: <?php $values = get_post_custom_values("Mood"); echo $values[0]; ?>
Thanks for your help!
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Hiding if custom field is empty’ is closed to new replies.