Home Forums General Issues update post object field


update post object field

  • Hi i’m trying to do a field update for a Post Object field type.
    Something like this:

    $doctor = get_field('doctor', $post_ID); //doctor is a Post Object field type.
    if( $doctor ){
    	update_field('field_548ee65c7d1ea', $doctor, $post_ID);
  • Hi @oleggen,

    Since the Post Object field contains an array of values, you will need to pass an array of values to the Update_field() something like the following:

    $doctor = get_field($field_key, $post_id);
    $value[] = array(//your_values);
    update_field( $field_key, $value, $post_id );

    You should also use try using the field_key on the get_field() function.

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

The topic ‘update post object field’ is closed to new replies.