How to query a loop with a custom field filter?

Hi,
I have a post loop that queries a custom post type. I want to filter the posts based on a custom field. Is it possible to do this?

I have a post type called “Property” and I’m using Advanced Custom Fields (ACF) for the custom fields. Specifically, I have a select field called “Location” and I would like to filter the posts based on the city location.


I did some research and tried to achieve this, but it doesn’t seem to be working. Maybe I misunderstood something.

Thank you all for your help.

1 Like

I think, teoreticaly, your approach should be correct. Try to remove the meta query and put inside your query loop this to text: {location}. Is it showing correct data for each item? (also with uppercase)?

Yes i have try it before but not work really :frowning: