Home › Forums › Add-ons › Repeater Field › Repeater only outputting the last row › Reply To: Repeater only outputting the last row
Yes they are both associated with a custom post type post.
I have the same setup working with another repeater and select. But this repeater contains a post object. This is reflected with the slight difference in the below code. The count in this setup just ignores the last two rows. If that is removed all rows are returned.
function acf_load_player_choices( $field ) {
// reset choices
$field['choices'] = array();
// if has rows
if ( have_rows( 'saints_squad' ) ) {
$i = 1;
// while has rows
while ( have_rows( 'saints_squad' ) ) {
// instantiate row
the_row();
// vars
$value = get_sub_field( 'player' );
$post = $value;
setup_postdata( $post );
if ( $i < 18 ) {
// append to choices
$field['choices'][ $post->post_title ] = $post->post_title;
}
wp_reset_postdata();
$i++;
}
}
// return the field
return $field;
}
add_filter( 'acf/load_field/name=saints_team_event', 'acf_load_player_choices' );
But this setup works.
Is there something I’m missing in the above that would cause problems with a second one?
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.