Hi
I have tried reading this: http://www.advancedcustomfields.com/resources/how-to/hiding-empty-fields/ but how do I get this whole line (indcluding <br/>
) to hide if empty?
<?php $field = get_field_object('titel' ); ?><b><?php echo $field['label']; ?>: </b><?php the_field('titel'); ?><br/>
Hi @Cheyens
The get_field_object function will also load in the value, so there is no need to use the_field as well.
Here is the complete code:
<?php $field = get_field_object('titel' ); ?>
<?php if( $field['value'] ): ?>
<b><?php echo $field['label']; ?>: </b><?php echo $field['value']; ?><br/>
<?php endif; ?>
Hi Elliot
Thank you so much. That hit the spot! 🙂