Home Forums Add-ons Repeater Field Automatically generate repeater fields Reply To: Automatically generate repeater fields

  • Hi @jetro157,

    I think the second one would be easier to achieve. If you only need to show the duration on the front-end, you can use the count() function on the repeater field. It should be something like this: count(get_field('repeater_field_name')).

    If you need to show it on the backend, you can use acf/save_post to update the duration field using update_field(). Maybe something like this:

    function my_acf_save_post( $post_id ) {
        $itinerary = get_field('itinerary_field_name');
        if ($itinerary){
            $duration = count($itinerary);
            update_field('duration_field_name', $duration, $post_id);
    // run after ACF saves the $_POST['acf'] data
    add_action('acf/save_post', 'my_acf_save_post', 20);

    I hope this helps.