I would like to be able to traverse a set of relationships so that I can display a list of Training in my Posts in an ordered way.
Posts -> Audience -> Courses -> Trainings
It is not useful to do a nested query as the Training must be ordered by delivery date so that the viewer can see upcoming training classes that relate to this post, and that it worked going forward into the future without having to associate all future trainings with more and more posts.
Hello and thank you for contacting the Toolset support.
You can build this using a few nested views, and some cleanup code. The views will return the IDs of the posts separated by comma. Then you can pass this view as a shortcode argument.
Check the custom code for cleaning up the view's markup. https://toolset.com/forums/topic/need-to-strip-views-formatting/
Note that you will need to use the legacy views to build this.
If you want to use the Blocks editor for the view, then you will need to hook into the view's query filter and programatically change the WP_Query arguments, especially 'post__in':
add_filter( 'wpv_filter_query', 'wpv_filter_query_callback', 10, 3 );
function wpv_filter_query_callback( $query_args, $view_settings, $view_id ) {
global $post;
if ( $view_id == 1234 ) {
//1. get the audiences related to the current post $post->ID
//2. get the courses from the audiances
//3. get the trainings from the courses
//4. $query_args['post__in'] = $trainings;
}
return $query_args;
}