Support

Account

Home Forums Backend Issues (wp-admin) How get fields from specific post and specific group

Solved

How get fields from specific post and specific group

  • How get fields from specific post and specific group?

    I have this code:
    // Get field from another post
    $source_fields = get_fields($another_post_id );
    // Update fields in this post
    foreach ($source_fields as $field_name => $field_value) {
    update_field($field_name, $field_value, $post_id);

    – i have many groups fields and in this case i need to use only specific group – group_6457959205b1b (ID 4985)

  • in case anyone out there, here’s what worked

    // Get field from another post
    $fields = acf_get_fields('group_6457959205b1b');
    // Update fields in this post
    foreach ($fields as $field) {
         $field_name = $field['name'];
         $field_value = get_field($field_name, $another_post_id);
         update_field($field_name, $field_value, $post_id);
         }
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.