Home › Forums › General Issues › How to filter custom field object by related custom field ? › Reply To: How to filter custom field object by related custom field ?
You cannot query a post type based on data stored for second post type.
You have a couple of choices.
1) You do a query on the second post type to get posts filtered by the custom field. You then use the returned post IDs to query and filter the first post type.
2) When saving post type 1 you copy the data in the meta fields from the related post type 2 to meta field for post type 1. You then can query post type 1 directly using this data.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.