Get CPT based on ACF Relationship Post Object Value

I have a CPT (school) that has an ACF relationship field (district) and on my School Directory page I am trying to list all schools while grouped within their District. I thought I could do a simple Query Builder looper where I filter by district equal to {{ post.id }} like so:

Here is a screenshot of some debugging I have gone through to try to confirm I have the same values.

One of my concerns or big questions here is that I’ve noticed in ACF the return format is “Post Object” so I thought perhaps that was an issue. I prefer this so I can easily use it for Dynamic Content loopers, but I’m wondering if this is causing me issue right now. I even tried changing to “Post ID” but still not getting the results I’m expecting.

Does ACF “Post Object” return format make a difference in what is queried in the Query Builder?

How do I fetch all school CPT post where the ACF Relationship Field has the current District in my parent looper selected?

Hey Nicholas,

Thanks for writing in!

You can test both the Post Object and the Post ID return format. In your layout, you may use {{dc:looper:debug_consumer}} to be able to see the post items being returned by your looper.

We would highly recommend the " JSM Show Post Metadata" plugin. This can help you check the post meta data when editing a single School district item.

If nothing is helping, we would be happy to double check your site if we can log in. You can create a secure note in your next reply with the following info:
– Link to your site
– WP login URL
– WP username
– WP password
– WP Administrator Role
– Confirmation that we can access and make changes to your site

To know how to create a secure note, please check this out: How The Forum Works

image

Best Regards.

When I attempt {{dc:looper:debug_consumer}} within a text component on my layout, I just get a bug icon but no data so not sure what I am doing wrong.

I’ve used that plugin before and I have a pretty good understanding of my data model and the values but not of Twig functions or what Cornerstone always expects to get the results I’m expecting, especially in these nested scenarios. I even have a Breadcrumb (elements) component that I’m trying to customize but it makes no sense how the label variable has two values (1 provided and 1 I didn’t), and when I inserted the district text it didn’t work as expected. At the moment these are not hierarchical but I’m thinking I should make them.

The big goal here is to group schools by district and I thought a simple “get X schools where district is the current one” would work.

Hey Nicholas,

It is best to have one thread for each issue to avoid getting mixed. We’'ll get to the first issue here. You should be using “District LIKE {{ post.id }}” in your Looper:

And you should be getting this:

Kindly let us know if this has worked out for you.

OMG! Thanks so much! Would have never thought to use District LIKE {{ post.id }} in looper like that, this is huge new approach for me and I’ll need it in several places across the site so THANK YOU so much!

As for the {{dc:looper:debug_consumer}} issue I’m not sure what you did to get that result but when I add it to this header component I still get the bug icon.

As for my other question, I went ahead and reposted it here as you requested. Sorry about that.