I'm trying to run a query loop that only outputs posts that have a value in their relationship. So there are Services Areas and City Pages. Some of the Service Areas do not yet have City Pages written for them, but will be adding over the next few months.
I want my query loop to only output Service Areas that have a related City Page. I can't seem to make it work.
Consider this setup:
CPTs: Service Areas and City Pages
Meta Box Relationship: City Pages to Service Areas
A Service Area post can have 0 or 1 or more City Page(s).
Sample Service Area with some City Pages:
Sample Service Area with no City Pages:
The objective is to only output the Service Area posts that have at least 1 connected/related City Page.
Service Areas query loop by default:
Service Areas query loop after implementing this Pro tutorial:
Steps in brief:
In the Bricks Query Loop PHP editor
Get all service area IDs.
Loop through each service area and for each, check if there is at least 1 connected city using MB's Relationship API. If so, store the service area ID in an array.