Well, I’m the author of Relevanssi and I’m very interested in getting Relevanssi and WPML to work together (I use WPML myself), I just haven’t had the time to do it yet.
The relevanssi_hits_filter
is one way to approach it. It gives you a list of hits found with the query, so it’s possible to go through them and discard the hits that are in the wrong language.
It’s on line 570 of Relevanssi 2.6.
$filter_data = array($hits, $q);
$hits_filters_applied = apply_filters('relevanssi_hits_filter', $filter_data);
$hits = $hits_filters_applied[0];
The first part of the data is an array of post objects, the second is the search query. You need to return an array containing an array of post objects in index 0.
That’s one way to approach it. Then there’s relevanssi_where
, which allows you to modify query restrictions. That’s what gets slapped in the end of the MySQL query that finds the hits. You could add some MySQL code that restricts the search to only current language (essentially in the shape of ” AND doc IN (list of allowed post ID’s) ” or ” AND doc NOT IN (list of forbidden post ID’s) “.
If you can come up with something that makes Relevanssi work with WPML, I’d be delighted to add it to Relevanssi core if necessary, since WPML is such a significant plugin. If WPML is active, user could choose to restrict the search to the active language or to search all languages.
You can email me directly at mikko at mikkosaari.fi.