Home Forums Add-ons Repeater Field Use a value from outside a repeater loop


Use a value from outside a repeater loop

  • I have done a bunch of research on this trying to find an answer. I have a value from outside the repeater field that I need to use in the repeater loop. The fields are all from the same page. I want to do something like the following.

    $variable = get_field('value');
    <?php if( have_rows('repeater') ): ?>
        <?php while( have_rows('repeater') ): the_row(); ?>											
    	<?php the_sub_field('some_value'); ?>
    	<?php echo $variable; ?>
    											<?php endwhile; ?>
    <?php endif; ?>
  • The code you posted should work if both pieces of code are in the same file (function if applicable)

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

You must be logged in to reply to this topic.