Home Forums ACF PRO if (have_rows()) not working Reply To: if (have_rows()) not working

  • @swennet So I’m not sure if it’s a typo, but when retrieving a value from an options page, you use ‘option’ (singular), not ‘options’ (plural).

    Also, the if statement will only return true or false. You need to loop through them and load the row’s data (the_row();) per loop iteration.

    So your code would look something similar to:

    if ( have_rows('my_repeater', 'option') ) : 
    	//Use while loop to loop through rows, the_row() will load the row's data
    	while( have_rows('my_repeater', 'option') ) : the_row();
    		// create variables for sub field values
    		$sub_field = get_sub_field('sub_field');
    	<li><?php echo $sub_field; ?></li>
    	<?php endwhile; ?>
    <?php endif; ?>