custom field display nothing if blank
-
Hi All,
I’ve a custom field which displays a date. What I’d like to do is not show the title of the custom field or it’s content if it’s blank, however, my code below still shows the title Date when there is no content. What’s wrong with the below?
<?php if( get_post_meta($key, 'date') !== '' ) { ?> <?php $key="date"; echo $key.' '; ?> <?php $key="date"; echo get_post_meta($post->ID, $key, true); ?> <?php } ?>
Should the above not be fine to use?
Thanks
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘custom field display nothing if blank’ is closed to new replies.