Hi there, I’m having some trouble using conditional statements within a Repeater Field. Within the repeater field admin panel side I have a true/false field which when ticked displays additional fields, which all works fine. My problem lies with mirroring this in my code:
<?php if( have_rows('project_images') ): ?>
<?php while( have_rows('project_images') ): the_row(); ?>
<?php
// Check if the caption yes/no box is ticked
if(get_field('image_caption'))
{
echo "<h3>".get_sub_field('image_caption_title')."</h3>".get_sub_field('image_caption_text')."<hr />";
}
?>
<?php endwhile; ?>
<?php endif; ?>
The code within the IF statement works fine outside of it. Any ideas? Thanks.
Never mind, fixed the problem. I was using “get_field” in the If statement rather than “get_sub_field”. It’s always the little things! 🙂