// Important: give your labels human readable names!
// Book store details
$book_shop_details = array(
'book_store_name',
'book_store_link',
'book_store_logo',
'book_title'
);
// Is there data in one of the fields?
$has_meta = false; //init
foreach( $book_shop_details as $detail ) {
if( get_field( $detail ) ) {
$has_meta = true;
continue; // Just need one meta field filled to create the div.
}
}
if( $has_meta ) {
echo '<div class="single-book">';
foreach( $book_shop_details as $detail ) {
$shop_detail = get_field( $detail );
if( $shop_detail ) {
$obj = get_field_object( $detail );
$label = $obj['label']; //field label
echo $label . ': '. $shop_detail;
}
}
echo '</div>';
}