Support

Account

Home Forums ACF PRO bi directional relationship update via code

Solving

bi directional relationship update via code

  • I made a relationship field between two post types and it works with the hook function i found on the acf site. When one post is saved the other post is updated to reflect the relationship.
    Based on this:
    https://www.advancedcustomfields.com/resources/bidirectional-relationships/

    But I imported some posts and they have the relationship on one side but the other side needs to be “updated”.
    I can make it work by going to each post individually and pressing update.
    This takes long.

    i tried running a wp_query to get all the posts and do wp_update_post, hoping this would trigger acf, but it doesnt. How can i trigger acf to save in a loop.

    Basically I need to get the acf hook update_value to run….

  • I got it working by looping through them all, getting the relationship field info and then just saving it right back via update_field…

    But there must be a way to easily get the hook update_value to run manually.
    I seem to only get it working when i press update post, but not when I use wp_update_post.

    I also tried wp_insert_post. Nope.

  • Hi,
    I have the same issue…
    Did you find a way to refresh/update relationship without open and save each post?

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

The topic ‘bi directional relationship update via code’ is closed to new replies.