
I’m running an if-loop to return a field that I have on my wordpress page, everything works fine except when I try to check if a field-group inside of the current loop has content and then return a . Somehow it looks like I’m stuck in the new loop and I’m not sure how to solve it.
I’m running advanced-custom fields and I have a Flexible group with a group inside.
<?php if( have_rows('content') ):?>
<?php while ( have_rows('content') ) : the_row();?>
<?php if( get_row_layout() == 'omrade' ): ?>
<div class="row">
<div class="col-md-12 padding-xs-none">
<div class="row">
<div class="col">
<?php echo '<h5 class="page-header">'.get_sub_field('rubrik').'</h5>'; ?>
</div>
</div>
</div>
<!-- Here is my if statement to see if close_by holds any info -->
<?php if( have_rows('close_by') ):?>
<div class="col-md-6">
<?php else:?>
<div class="col-md-12">
<?php endif;?>
<!-- This should be outputted either way, but if "close_by" exists it wont output this at all -->
<?php echo get_field('omrade_text');?>
</div>
</div>
<?php endif;?>
<?php endwhile;?>
<?php endif; ?>
Try altering your if syntax to use if (){...} else {...}
instead of if():... else:... endif;
Thank you, I got it working with that 🙂