php do not show custom field value if its blank
Description
If a custom field for a post is blank then this code will ensure that anything in that div doesn’t appear as well. Also this code will allow you to put a replacement text or code in case the field is empty. Just replace “url” with the name of the custom field of your choice.
If a custom field for a post is blank then this code will ensure that anything in that div doesn’t appear as well. Also this code will allow you to put a replacement text or code in case the field is empty. Just replace “url” with the name of the custom field of your choice.
PHP Source Code
<?php if($values = get_post_custom_values("url")): ?>
Custom Field has a Value
<!--This is what you want to see if the custom field is filled out-->
<?php else: ?>
Custom Field has a no Value
<!--This is what you want to see if the custom field is NOT filled out-->
<!--If you do not want to see anything then do not add any code here-->
<?php endif; ?>