skip to Main Content

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?

3

Answers


  1. Chosen as BEST ANSWER

    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');
    

  2. <?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.

    Login or Signup to reply.
    1. To get ACF Repeater field you have to use ‘echo get_sub_field();’ or ‘the_sub_field();’
    2. For ACF option page you can use the following code:
        <?php if( have_rows('repeater_field_name', 'option') ): 
          while ( have_rows('repeater_field_name', 'option') ) : the_row();
           the_sub_field('yourfieldname'); 
         endwhile;
       endif; ?>
    
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search