For example, suppose that your View ID is 12345 and the target status posts IDs are 4, 6 & 8 and the involved relationship slug is "membership-status-person", then the function will look like this:
add_filter( 'wpv_filter_query', 'filter_specific_status_fn', 1000 , 3 );
function filter_specific_status_fn( $query_args, $view_settings ) {
if ( !is_admin() && ( isset($view_settings['view_id']) && $view_settings['view_id'] == 12345) ) {
// IDs of the required statuses
$req_statuses = array(4, 6, 8);
foreach ( $req_statuses as $post_array ) {
// get parent post in a relationship
$query_by_element = $post_array; // ID of post to get relationship from
$relationship = 'membership-status-person'; // relationship slug
$query_by_role_name = 'parent'; // $query_by_element is a parent in this relation
$limit = 999999; // defaults
$offset = 0; // defaults
$args = array(); //nothing needed
$return = 'post_id'; // We want Post ID
$role_name_to_return = 'child'; // We want child.
$get_results = toolset_get_related_posts(
$query_by_element,
$relationship,
$query_by_role_name,
$limit,
$offset,
$args,
$return,
$role_name_to_return
);
foreach ($get_results as $get_result ) {
$query_args['post__in'][] = $get_result;
}
}
}
return $query_args;
}
I hope this helps and for more personalized assistance around custom code, you can also consider hiring a professional from our list of recommended contractors: https://toolset.com/contractors/