Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Mikko Saari

    (@msaari)

    Relevanssi doesn’t know anything about those variables, and promptly ignores them. You need to add the support for them yourself.

    There are two approaches: before search or after search. You can add a filtering function on relevanssi_modify_wp_query and convert those query variables to something Relevanssi can understand (for example post__in listing the allowed posts), or you can use a relevanssi_hits_filter filter function to process the results Relevanssi finds and weed out the unconnected posts.

    Thread Starter modulbuero

    (@antwortzeit)

    Hey,

    thanks for the quick reply. I went with relevanssi_hits_filter and it works like a charm. I’ll leave the code here in case anybody wants to use it:

    function antwortzeit_relevanssi_hits_filter($hits, $zwei, $drei, $vier) {
    	if(get_query_var('connected_items') && get_query_var('connected_type')) {
    		foreach($hits[0] as $key => $hit) {
    			if(p2p_type(get_query_var('connected_type'))->get_p2p_id( $hit->ID, get_query_var('connected_items') ) ) {} else {
    				unset($hits[0][$key]);
    			}
    		}
    	}
    	$hits[0] = array_slice(array_filter($hits[0]), 0);
    	return $hits;
    }
    add_filter('relevanssi_hits_filter', 'antwortzeit_relevanssi_hits_filter', 20);

    Best,

    Christian

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Relevanssi ignores posts2posts query_vars’ is closed to new replies.