Support

Account

Home Forums Add-ons Repeater Field Repeater field returns nothing from a Template Reply To: Repeater field returns nothing from a Template

  • get_field, have_rows, most fields all work the same. They assume the post_id of the current post. Using them outside the loop without supplying the post ID is an incorrect way to use them.

    If, like you say, you don’t want to use the current post ID then even more so you should be supplying the post ID if you want to get values from a specific post.

    Going back to the fist code of the template you posted, if you want to use a specific post ID then what query is this looping over?

    <?php while ( have_posts() ) : the_post(); ?>

    Plus, there is a second loop in the template code after you include your template.

    At the top of the template there is this code

    <section style="background-image:url(<?php the_field("niche_header_banner_image"); ?>); ....
    This is outside the loop, it may be returning the value from the current post, or it may not, it’s using whatever WP considers to be the post ID at this point, which could change based on code that has run before this is called. If this field is attached to a specific post then you need to supply the post ID. The post ID could be 'options' if this is on an options page.

    All I can go by is the code that you supplied so far, you need to start at the top of the page template and ensure you’re calling the ACF function properly.