I am trying to make a view in which information of three many-many related post types are combined: Activities, Locations and Multimedia.
The Activity view enables you to search on activity features and shows a map with:
- activity markers (relationship activity-location)
- activity images (relationship activity-multimedia)
How can I use the related value (for example via a view, filtered on relationship) into the following fields (see ???):
1) [wpv-map-marker map_id="map-search" marker_id="marker-[wpv-post-id]" marker_field="???"
2) [types field='???' width='190' height='140' align='none'][/types]
Your request relates to outputting fields from a different context, e.g. from the context of an activity use an address field that comes from a related location; from an activity display images that belong to a related multimedia post.
When you insert the shortcodes to output fields (using the Fields and Views button) a Post Selection tab is normally available where you can specify an alternate source for the data to the current post, which will add an 'item' attribute to the shortcode which specifies the other source.
But this only works where the alternate source is unique, in a one-to-many relationship for example where from a child post you want to output the title of the parent. There can be only one parent, and the item attribute will correctly identify this unique post to take the title from.
But it doesn't work the other way, where the current context is the parent post and you want to output the child post title, because there could be many child posts.
In that case you would need to create a View to display all of the possible child post titles which includes a Query Filter to specify the origin parent they belong to.
Your case is similar.
Because these are many-to-many relationships there could be many markers for that activity (even if, for a particular activity there is only one), or there could be many multimedia images for the same activity.
So in each case you need to create a new View (with a relationship Query Filter to connect it to the current activity) which in the first case will output a marker for the current location (note the shift in context) and in the second case will output the image for the current multimedia post (again, the shift in context).
I have 2 views which return the required data for each activity, for example:
[wpv-view name="map-related-locations"]: "Amsterdam, Netherlands"
[wpv-view name="featured-image-related-media"]: 1 image of Amsterdam
How can I refer to these views in the following fields (inserting the views like below doesn't work right):
No, you need to move those fields out of the current View into the related post Views.
You must output those shortcodes from the secondary Views which will have the correct context, not from the original View whose context is activity posts.
The image field needs to be output by the View that queries multimedia posts.
The map marker shortcode needs to be in the output of the View that queries locations.
Where in the original View you insert those fields insert the related Views instead.