Support

Account

Home Forums Add-ons Repeater Field Unable to get the repeater field working (Never passes has_sub_field while loop) Reply To: Unable to get the repeater field working (Never passes has_sub_field while loop)

  • Hi @rpk

    I think the issue is that you are using the wrong field name for the has_sub_field loop.

    This function requires the field name to be the ‘repeater field’ name, not one of the sub fields.

    Your code:

    
    <?php if(get_field( 'pro_repeatertest' ) ): ?>
    		<?php echo 'We are in the if loop'; ?>
    		<ul>
    		<?php while( has_sub_field( 'pro_food' ) ): ?>
    

    Should be changed to:

    
    <?php if(get_field( 'pro_repeatertest' ) ): ?>
    		<?php echo 'We are in the if loop'; ?>
    		<ul>
    		<?php while( has_sub_field( 'pro_repeatertest' ) ): ?>
    

    Thanks
    E