Home Forums General Issues Get post ID where a value is set in acf field


Get post ID where a value is set in acf field

  • Hi there.

    I have several posts.
    Every post has a field called: “area_no”.
    In this area_no we have a set value for each post.

    How can i in a php loop search for a post that has that set value in area_no and input some data into another field in that post called: “available_spots” ?

    Let’s say that area_no is “7756” and I then want to update the field “available_spots” in the same post that area_no is “7756”. This is gonna be done on about 40 posts, so I have this in a loop to be able to get the data from the API.

    Have not worked that much with ACF in the past, so would be glad if anyone could give a little hand here. Thanks.

  • Anybody know how I can update a field with a value by searching for meta_data “area_no” ?

  • You would need to do a WP query to get all the posts with that value, see this

    loop over the posts and then use update_field() to update a value in another field of that post inside the loop.

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

You must be logged in to reply to this topic.