Home Forums ACF PRO Querying relationship fields Reply To: Querying relationship fields

  • Hi @tva

    I’m afraid that is hard to achieve and will consume a lot of resources. Basically, you can get the IDs of the posts that have “restaurant” as the category. After that, you can create queries by looping through these IDs to check if the value contains one of the ID. Unfortunately, it will generate a very long query when you have a lot of posts in a category.

    What I suggest is to create a dummy field group for your Area post type to list all of the categories from the selected listing. That way, you can query the area based on the dummy field instead.

    You can do it by using the acf/save_post hook to get all of the categories of the selected listings when you save the post and then use the update_field() function to update the dummy field.

    I hope this makes sense 🙂