Support

Account

Home Forums Add-ons Repeater Field Triple level of nesting and delete_row

Helping

Triple level of nesting and delete_row

  • Good afternoon
    I know that there is a function: delete_sub_row / delete_row

    How should I use it if I have this order:
    mainrow (here you need to select the first of the repeater fields)
    subrow (here you need to select the second of the repeater field)
    items (here you need to select the first of the repeater fields)
    photos (here you need to select the first of the repeater field)

    Help please)

  • function photo_remove_test($postID,$mainrow,$subrow,$items,$photos){
    	while( have_rows('mainrow',$postID) ) : the_row();
    		$flex_index1 = get_row_index();
    		if ($flex_index1 == $mainrow) {
    			while( have_rows('subrow') ) : the_row();
    				$flex_index2 = get_row_index();
    				if ($flex_index2 == $subrow) {
    					while( have_rows('items') ) : the_row();
    						$flex_index3 = get_row_index();
    						if ($flex_index3 == $items) {
    							$photosArr = get_sub_field('photos');
    							foreach($photosArr as $key => $photo):
    								if ($key == $photos) {
    									if (delete_sub_row('photos', $photos)):
    										break;
    									endif;
    								}
    							endforeach;
    						}
    					endwhile;
    				}
    			endwhile;
    		}
    	endwhile;
    }
    
    //photo_remove_test(26,1,1,1,2);

    Working! GOOD!

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.