I am trying to update a repeater subfield with a number so that the repeaters will be less confusing. This works great if I am not using the gutenberg editor and it is not a block.
I want to be able to create a block that has this functionality.
Here is my code:
function slider_count($post){
$block_post_id = get_the_ID();
if( have_rows('slides') ){
$count = 0;
while( have_rows('slides') ){
the_row();
$count++;
$slider_count = 'Slider Number '.$count.'';
update_sub_field( 'slider_number', $slider_count );
}
}
}
add_action('acf/save_post', 'slider_count', 20);
I think part of the problem is that when using gutenberg editor, the page does not refresh when you update or publish the post.
Any idea how I can get it to work?