Support

Account

Home Forums Add-ons Repeater Field Repeater Field Bug: Looping First Field

Solved

Repeater Field Bug: Looping First Field

  • Hello there, hope everyone is well

    I’ll get straight to the point on this one. I’ve had a look all over the internet for a solution but no results or posts even closely relating.

    The problem is that i’ve created a repeater field to contain two simple fields, one is the title for the content ‘tip_title’(text field) and the other is the content associated ‘tip_content‘(text area) as shown below:-

    <div id="archiveTipBox">
    				
    				<?php if(get_field('archive_tips')): ?>
    					<?php while(has_sub_field('archive_tips')): ?>
    						
    						<div id="archiveTipsBoxContent">
    							<div class="tipTitle"><?php echo the_sub_field('tip_title');?></div>
    							
    							<div class="tipContent">
    								<?php echo the_sub_field('tip_content');?>
    							</div>
    						</div>
    					
    					<?php endwhile; ?>		
    				<?php endif; ?>
    
    				</div>

    It has no problem repeating tip_title for each entry but for tip_content it just shows the first one in every single entry which makes no sense

    Any help on this would be greatly appreciated as i’m completely lost

    I’ve also attached these images just to show you in more detail

  • Perhaps this might help you.

    <div id="archiveTipBox">
        <?php if( have_rows('archive_tips') ):
            while ( have_rows('archive_tips') ) : the_row(); ?>
                <div id="archiveTipsBoxContent">
                    <div class="tipTitle"><?php the_sub_field('tip_title'); ?></div>
                    <div class="tipContent">
                        <?php the_sub_field('tip_content'); ?>
                    </div>
                </div>
            <?php endwhile; ?>
        <?php  else :
        endif; ?>
    </div>
  • Hi The code provided by @gwundrig should work perfectly,

    In your code you are missing the_row();

    which enables the repeater to loop through all the rows in the repeater.

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Repeater Field Bug: Looping First Field’ is closed to new replies.