Home Forums Backend Issues (wp-admin) Update ACF Post Object with wp cli not working


Update ACF Post Object with wp cli not working

  • Hello everyone,

    I have a problem with the update of a post object field.
    I use wp-cli to insert a new post then I use the update_field function to update fields:

    update_field('field_61deaf970e5da', $array, $post_id);

    This works for text fields (title for example) but not for post objects.

    Using WordPress 5.9.2 and ACF 5.12

    Many thanks for your suggestions

  • 2 things to check for.

    A post object field that only allows one selection is not stored as an array in the DB.

    If the post object field allows multiple then it is stored as an array but all of the IDs in the array are stored as strings and not integers.

  • Hello John,

    Thank you for your answer.

    My post object allows multiple, is nullable, is filtered by Post Type ‘Page’ and allows all taxonomies.

    Trying to add
    [0] => Test

    I have a published page named ‘Test’ but still not working.

  • If I pass the ID of the page instead of the name to my post object, It seems to work.

    Thank you.

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

You must be logged in to reply to this topic.