Support

Account

Home Forums General Issues Insert Relationship Fields Using update_field()

Solved

Insert Relationship Fields Using update_field()

  • Can I update a relationship field of a specific post using the update_field() function? If Yes could you please explain how I would achieve this.
    NB: The Post I’m linking to are already inserted and I would like to know how I’m going to link them

  • Hi @alfkonee

    Sure, the update_field function can be used to update any postmeta value.
    All you need to do is create an array containing the post ID’s you wish to save as the relationship value, and then use the update_field function to save that array ($value) to the post.

    The docs will explain what parameters are needed for the function to work.

    Thanks
    E

  • Hey @Elliot,

    when i set some posts into a relationship Field with update_field, they will be set only after re-saving the post. why?

  • Using the Field Key (field_535e34692df42) was the solution!

  • I am trying to update relationship field and its saving the data but not showing in wp-api until I save them from wp-admin. is there any solution for this?

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

The topic ‘Insert Relationship Fields Using update_field()’ is closed to new replies.