I checked the view you created and the issue you have.
As shared before:
Well - normally, the text search should search on the fields that belongs to post type you set your view to query.
So, for example, if you have post type A (parent) with custom fields (aa,bb,cc) and post type B (child) with custom fields (dd,ee,ff) in many-to-many relationship and if you build the view to query post type B (child) then it should apply search on fields belongs to post type B that is fields (dd,ee,ff).
To workaround it I tried few hooks and I get the desired post but somehow post__in argument is not working with Relevanssi.
You can check the different hook I try and try to hook in the post__in argument in order to get your desired result under the "Custom Code" section offered by Toolset:
=> lien caché
//add_filter( 'relevanssi_modify_wp_query', 'func_rlv_adjust_search' );
function func_rlv_adjust_search( $query ) {
if(isset($_GET['wpv_post_search']) and $_GET['wpv_post_search']!='') {
remove_filter( 'relevanssi_modify_wp_query', 'func_rlv_adjust_search' );
$args = array(
's' => $_GET['wpv_post_search'],
'post_types' => array('person'),
'fields' => 'ids',
'relevanssi' => true,
);
$person_query = new WP_Query( $args );
$args = array(
's' => $_GET['wpv_post_search'],
'post_types' => array('internment'),
'fields' => 'ids',
'relevanssi' => true,
);
$internment_query = new WP_Query( $args );
$parent_person_posts = array();
foreach($internment_query->posts as $k=>$v):
$parent_person_posts[] = toolset_get_related_post($v,'person-to-internment');
endforeach;
$final_res = array_merge($person_query->posts,$parent_person_posts);
$query->query_vars['post__in'] = join(",",$final_res);
// relevanssi_do_query( $query );
add_filter( 'relevanssi_modify_wp_query', 'func_rlv_adjust_search' );
$query->query_vars['post__in'] = join(",",$final_res);
$query->set('post__in',join(",",$final_res));
}
// return $query;
}
//add_filter( 'relevanssi_results', 'rlv_rating_weights');
function rlv_rating_weights( $results ) {
remove_filter( 'relevanssi_results', 'rlv_rating_weights');
$internment_parents = do_shortcode('[wpv-view name="get-related-internment-posts" cached="off"]');
$internment_parents = explode(",",trim( $internment_parents));
$final = array_merge($results,$internment_parents);
$final_results = array();
foreach($final as $k=>$v):
$final_results[$v] = 1;
endforeach;
//add_filter('relevanssi_results', 'rlv_rating_weights');
return $final_results;
}
Can you please get in touch with Relevanssi support and check with them how we can hook in the post__in argument using the above hook.