Thnaks for the code.
I modified it in this way:
add_filter( 'wpv_filter_query', 'func_filter_with_multiple_parents', 10, 3 );
function func_filter_with_multiple_parents( $query, $view_settings, $view_id ) {
global $WP_Views;
if( $view_id == 380 ) {
$parent1 = $WP_Views->view_shortcode_attributes[0]['busid'];
$parent2 = $WP_Views->view_shortcode_attributes[0]['trajectid'];
$custom_query = new WP_Query(
array(
'post_type' => 'timeslot', /// change the post_type slug if required
'fields'=> 'ids',
'posts_per_page' => -1,
'toolset_relationships' => array(
array(
'role' => 'child',
'related_to' =>$parent1,
'relationship' => 'bus-timeslot' /// change the relationship slug if required
),
array(
'role' => 'child',
'related_to' => $parent2 ,
'relationship' => 'traject-timeslot' /// change the relationship slug if required
)
),
'order' => 'ASC',
)
);
$related_ids = $custom_query->posts;
// passing found related ids
$query['post__in'] = $related_ids;
}
return $query;
}
I tested it with some ids and it works:
[wpv-view name="timeslots-test" trajectid="191" busid="317"]
But it doesn't work where I need.
I've also a many-to-many relationship btw trajects and busses. I built a view to display a list of intermediary posts of this relationship. There I want to include the other view in this way:
[wpv-view name="timeslots-test" trajectid="[wpv-post-id item='@traject-bus.parent']" busid="[wpv-post-id item='@traject-bus.child']"]
This gives me:
"The site is experiencing technical difficulties."
I've also made a test including just this in the view:
trajectid="[wpv-post-id item='@traject-bus.parent']" busid="[wpv-post-id item='@traject-bus.child']"
And it works fine, the output is correct, a list of parent and child ids of the intermediary CPT.
any idea?