Basically, I have some code that should work like this:
<?php while ( have_rows( 'first_section' ): the_row(); ?>
...
Display some stuff
...
<?php if ( get_row_index() > 6 ) break; ?>
<?php endwhile; ?>
<?php while ( have_rows( 'second_section' ): the_row(); ?>
...
Display some stuff
...
<?php endwhile; ?>
However, the second section doesn’t display, and I’m pretty sure it has something to do with breaking out of the previous loop, as if I remove just the break
statement everything’s fine.
Otherwise, I can sort of fix it by adding this just before the second section:
<?php echo ( have_rows( 'second_section' ) ) ? "Not Broken!" : "Broken!"; ?>
But, that also presents the weird behavior of echoing “Broken!” and then actually displaying the second section. So, somehow calling have_rows()
twice fixes the rigging of the loop that was broken by the break
, while also inappropriately returning false
the first time it’s called.