I created an ACF repeater field on my options page but I'm unable to retrieve the value using get_field()
. How do I retrieve the repeater value?
CodePudding user response:
According to ACF - Get values from an options page, you need to add 'option'
as the second parameter in get_field()
.
See this example:
$variable = get_field('field_name', 'option');
CodePudding user response:
<?php if( have_rows('repeater', 'option') ): ?>
<ul>
<?php while( have_rows('repeater', 'option') ): the_row(); ?>
<li><?php the_sub_field('title'); ?></li>
<?php endwhile; ?>
</ul>
Replace repeater with the name of your field and inside the_sub_field() with what you have included.