Home › Forums › Add-ons › Repeater Field › Repeater field returns nothing from a Template › Reply To: Repeater field returns nothing from a Template
Your main loop starts with this line
<?php while ( have_posts() ) : the_post(); ?>
and ends with the matching
<?php endwhile; // end of the loop. ?>
Your problem is that most of your calls get_field()
and other ACF functions is outside the loop, so the current $post->ID
value may or may not be used. If you use ACF functions outside of "The Loop"
then you must supply the post ID when calling ACF functions. Not using adding the post ID outside the loop will have unpredictable results.
You can get the current post ID outside of the loop using
$post_id = 0;
$queried_object = get_queried_object();
if (isset($queried_object->ID)) {
$post_id = $queried_object->ID
}
$post_id = $queried_object->ID;
then call ACF functions like
$value = get_field('my_field_name', $post_id);
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.