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
    			// 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;
    	// 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?