Support

Account

Home Forums Add-ons Repeater Field Repeater Fields Not Showing Up On Front End

Solved

Repeater Fields Not Showing Up On Front End

  • Hi Folks,

    I am having an issue with adding a repeater field to my site.

    Below is a screenshot of AFC in wp and then below that is the code I have added. What am I doing wrong.

    https://drive.google.com/file/d/1tPwc5_SnorpJQ3z-Cwz4nDGMykBl5Eht/view?usp=sharing

    <?php if( have_rows(‘documents_area’) ):
    while( have_rows(‘documents_area’) ) : the_row(); ?>

    <p><?php $sub_value = get_sub_field(‘document_text’); ?></p>

    <?php endwhile; ?>
    <?php else : ?>
    <?php endif; ?>

  • You need to echo the field value, not just return it. get_sub_field() is for returning it (i. e. to store it in a variable and do something with it afterwards), and for directly echoing it you would use the_sub_field() (spot the little difference between “get” and “the”).

    However, you can, of course, also go the little detour of storing the value in a variable and then echoing that variable; so, in your example, you would do:

    
    $sub_value = get_sub_field(‘document_text’);
    …
    …
    echo($sub_value);
    
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.