Home › Forums › ACF PRO › Querying relationship fields › Reply To: Querying relationship fields
Hi, thanks for your reply.
I’ll try and explain my situation, for example: i have 2 post types “areas” and “listings”. All listings can be assigned to 1 area (via the relationship field). Each listing can have 1 or more categories.
Let’s say i have 3 areas: Amsterdam, New York and Sydney.
Let’s say i have 3 listings: Listing 1, Listing 2 and Listing 3.
Let’s say Listing 1 is assigned to Amsterdam, Listing 2 is assigned to New York and Listing 3 is assigned to Sydney.
Let’s say both Listing 1 and Listing 3 have a category called “restaurant”.
What i want to be able to do is create an archive of areas and query those archives by the category assigned to the listings.
So normally the archive page for areas would show Amsterdam, New York and Sydney. With the query i want to built i want it to only show Amsterdam and Sydney because these areas are related to the listings that have the “restaurant” category.
It’s a bit complex and i actually nearly there. However i’m not sure if im going about this the right way.
On a side note my relationship field returns an array that looks like:
Array ( [0] => Array ( [0] => 177 ) [1] => [2] => Array ( [0] => 164 ) )
While for it to become useful it should look like:
Array ( [0] => 177 [1] => 174 )
Thanks!
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.