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!
🚀 This week’s session of ACF Chat Fridays dips into the preliminary results of our first ever user survey. Don’t miss it! https://t.co/3UtvQbDwNm pic.twitter.com/kMwhaJTkZc— Advanced Custom Fields (@wp_acf) May 9, 2023
© 2023 Advanced Custom Fields.