Skip to content
Advertisement

WordPress query by ACF relationship field

I have a custom post type “building” and another custom post type “architect”. Building are related to architects via an ACF relationship field.

In the single-architect page I want to display a list of the buildings that are associated to that particular architect.

So far I have achieved this by doing the following:

JavaScript

However this doese not seem very efficient and I am looking to introduce the relationship into the query itself, which I have tried by doing this:

JavaScript

Which is not working, it does not return anything…

Can you see what am I doing wrong or do you have any other idea to approach this situation?

Advertisement

Answer

This is the solution that I’m currently using. I looks quite solid to me.

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement