Support

Account

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

  • 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!