Hi I know that I can use a conditional statement to check if a particular field is empty.
But how would I do this if I want to check that all fields within a flexible content loop are empty?
You’d need to check every field. I would probably do something like
$sub_fields = array(
'create',
'an',
'array',
'of',
'sub_field',
'names',
);
if (have_rows('flex_field')) {
while (have_rows('flex_field')) {
the_row();
$has_content = false;
foreach ($sub_fields as $sub_field()) {
if (get_sub_field($sub_field)) {
// flex field has content
$has_content = true;
// do not need to continue loop once you find content
break;
} // end if get sub field
} // end foreach sub field
if (!$has_content) {
// this layout has no content
// skip it
continue;
} // end if !content
// *********************************************
// code to display layout here
// *********************************************
} // end while have rows
} // end if have rows