Custom Fields: Activity, Destinations, Public data
Relationship: Every activity has a destination
Public data is a custom field that appears in all my custom fields
What I want to do is by using WP_Query how to get all ‘Activities’ of a specific ‘Destination’ by using the custom field public data
Example:
Imagine Destination object created
It contains some metadata and custom field named public data
I want to query on all activities by using the custom field public data inside destination.
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.