Support

Account

Home Forums General Issues Data Picker in ACF wp_insert_post

Solved

Data Picker in ACF wp_insert_post

  • Hello
    Help me please
    I used wp_insert_post to create new post in cpt
    what needs to be sent to the field “meta_input” add to Data Picker in ACF?
    when I send in data (ex 2029) POST all right – https://prnt.sc/1x73dvk
    but in new post acf field (Data Picker) only 1970 – https://prnt.sc/1x72yu8
    for other fields all ok

    My code like this

    $advert_name = $_POST[‘advert_name’];
    $advert_rent_date = $_POST[‘advert_rent_date’];
    
    $advert_new = [
    ‘ID’ => ”,
    ‘post_type’ => ‘offers’,
    ‘meta_input’ => [
    ‘name’ => $advert_name,
    
    ‘date’ => $advert_rent_date
    ],
    ‘post_content’ => $advert_desc,
    ‘post_title’ => $advert_title,
    ‘post_status’ => ‘pending’
    ];
    
    $post_id = wp_insert_post($advert_new);
  • The date field must be in the format “YYYMMDD”

    You must also set the acf field key reference. The name of the field is the same as your field name prepended with an underscore, example: “_date” and the value of this field is the field key for the date field, example: “field_123456789”

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.