So for brevity sake, I didn’t want to post every permutation of code that I tried. But taking a second look through them I realized I had some arguments out of order on one and it now seems to work. This will essentially “shift” the first layout (row?) off of the flex component:
delete_row('community_flex_components', 1, 999)
So given the warning about running delete_row()
inside of have_rows
loop, is the following an effective way to properly empty a flex component?
$length = count(get_field('community_flex_components', 999));
for ($i = 0; $i < $length; $i++) {
delete_row('community_flex_components', 1, 999);
}
It seems kind of ugly but I’m not immediately clear of any other way to do it. Appreciate any tips or insight.