Home › Forums › Add-ons › Repeater Field › Repeater Field
Hello,
I made a custom user page with ACF Pro for frontend editing.
All fields on this page are showing in custom posts type by the author.
Everything is working fine with fields, but not working at all with repeater.
I’m using the following snippet:
<?php $festa = get_field('musicians_events','user_'. $author_id); ?>
<?php
// check if the repeater field has rows of data
if( have_rows($festa) ):
// loop through the rows of data
while ( have_rows($festa) ) : the_row();
// display a sub field value
the_sub_field('show_venue');
endwhile;
else :
echo "no rows found";
endif;
?>
Returning always “no rows found”.
Thank you!!
Jeffe
What do you get when you execute this before your if statement?
die(var_dump($festa));
Also, is this within a loop? I am not sure your post ID is valid, I’d try:
<?php $festa = get_field('musicians_events'); ?>
or
<?php $festa = get_field('musicians_events', get_the_ID()); ?>
I needed an option for display content wether empty or not, and then the conditionals for rows, so for all of them I’ve included ” ‘user_’.$author_id ” :
<?php $festa = get_field('musicians_events', 'user_'.$author_id); ?>
Then I called the variable :
if(!empty($festa)){
........
}
The same for rows:
<?php if( have_rows('musicians_events', 'user_'.$author_id)): // check for repeater fields ?>
<?php while ( have_rows('musicians_events', 'user_'.$author_id)) : the_row(); // loop through the repeater fields ?>
Now everything is working fine!!
Thank you!!
Best
Jeffe
I have two repeater fields, the second is duplicated from the first. The first one works fine, but the second one does not return any data.
The php for the problematic repeater is as follows:
<?php if ( have_rows('faq_column_2') ) :
while ( have_rows('faq_column_2') ) :
the_row(); ?>
<div class="faq_accordian">
<div class="title"><?php the_sub_field('question_col2'); ?></div>
<div class="copy"><?php the_sub_field('answer_col2'); ?></div>
</div>
<?php endwhile;
else :
echo ('no rows found');
endif; ?>
My field names match up as shown in this screenshot:
I have tried rewriting the code (rather than copy/paste), I deleted the ACF plugin, uploaded the latest version, edited the sub fields to have a different name, and no luck. Then I deleted the repeater field, added a new one with all new names, still no luck.
I tried a var_dump
as described by @csaborio, and it returns all my data successfully.
The repeater, however, always returns “no rows found”. Very strange. Any ideas?
You must be logged in to reply to this topic.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.