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 🙂
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.