Reverse Search Based On ACF Relationship Field

Share Now

The scenario:
Two custom post types: Event & Sponsor.

Now every Event has multiple Sponsors…Which was set up by the ACF relation field for the Event Page.

Now we have Single Sponsor Pages too. All we want to do is show all events that were sponsored by our SPONSOR on the single sponsor page.

#Method :
1. Get The Sponsor ID from the single sponsor page.
2. Print All Event In a Query on the bottom of the sponsor page.
3. Get all the Sponsor IDs of that Event in an array.
4. Now check that check if that Single Sponsor’s ID is available in the Event’s SPONSOR ARRAY.
5. if available then print the EVENT CARD.
6. Unset the array [important for loop to work perfectly, unless the array will keep the old data]

Picture of Nahid Mahamud

Nahid Mahamud

Web Developer | Graphic Designer | WordPress & Woo-commerce Expert