ACF Repeater data not showing

27 views Asked by At

I have custom repeter and custom data updated but in db stored diffrent type here is my code

add_action('acf/init', 'acf_add_custom_repeater_field');

function acf_add_custom_repeater_field() {
    if (function_exists('acf_add_local_field_group')) {
        acf_add_local_field_group(array(
            'key' => 'group_custom_repeater',
            'title' => 'Custom Repeater',
            'fields' => array(
                array(
                    'key' => 'field_custom_repeater',
                    'label' => 'Custom Repeater',
                    'name' => 'custom_repeater',
                    'type' => 'repeater',
                    'layout' => 'block', 
                    'sub_fields' => array(
                        array(
                            'key' => 'field_type',
                            'label' => 'Type',
                            'name' => 'type',
                            'type' => 'text',
                        ),
                        array(
                            'key' => 'field_finance',
                            'label' => 'Finance',
                            'name' => 'finance',
                            'type' => 'text',
                        ),
                        array(
                            'key' => 'field_frequency',
                            'label' => 'Frequency',
                            'name' => 'frequency',
                            'type' => 'text',
                        ),
                        array(
                            'key' => 'field_description',
                            'label' => 'Description',
                            'name' => 'description',
                            'type' => 'textarea',
                        ),
                        array(
                            'key' => 'field_amount',
                            'label' => 'Amount',
                            'name' => 'amount',
                            'type' => 'number',
                        ),
                    ),
                ),
            ),
            'location' => array(
                array(
                    array(
                        'param' => 'post_type',
                        'operator' => '==',
                        'value' => 'consumer-lending-app', 
                    ),
                ),
            ),
        ));
    }
}
$post_id = 1173;
$post_meta = get_post_meta($post_id);
$field_key = "custom_repeater";
$value = array(
    array(
        "field_type"   => "151",
    )
);
update_field( $field_key, $value, $post_id );
foreach ($post_meta as $key => $value) {
    echo 'Meta Key: ' . $key . ', Meta Value: ' . implode(', ', $value) . '<br>';
}

I got Meta Key: custom_repeater, Meta Value: a:1:{i:0;a:1:{s:10:"field_type";s:3:"151";}} Meta Key: _custom_repeater, Meta Value:

but I am expacted this format Meta Key: group_custom_repeater_custom_repeater_0_field_type, Meta Value:"151" Meta Key: _group_custom_repeater_custom_repeater_0_field_type, Meta Value:"151"

0

There are 0 answers