On the front-end, in building out a template file for a custom post type, how do I hide empty fields?
I’m experimenting with calling the data in different ways using different functions you’ve provided including
Right now, I’m using the bulk display of get_field_objects() but as I learn and go along, I’m probably going to code out the template using the_field for each of the fields, but how to prevent empty fields from being displayed?
As an update to this, this is the snippet I’m currently using, but it is not working.
<?php $fields = get_field_objects();
if( $fields != "")
foreach( $fields as $field_name => $field )
echo '<div class="single-custom-field">';
echo '<h2>' . $field['label'] . '</h2>'; echo $field['value'];
That’s right on the money. Thank you for the quick reply!