Are you using any other filters for taxonomies?
If you add this code to functions.php and do a search, what do you get?
add_filter('relevanssi_query_filter', 'query_check');
function query_check($query) {
var_dump($query);
return $query;
}
Thread Starter
olorin
(@olorin)
Here’s what i get:
string(321) "SELECT *, title * 10 + content + comment * 0.75 + tag * 0.75 + link * 0 + author + category * 0.75 + excerpt + taxonomy + customfield + mysqlcolumn AS tf FROM wp_relevanssi WHERE term = 'empire' AND ((doc IN (SELECT DISTINCT(ID) FROM wp_posts WHERE post_type IN ('post','page','attachment'))) OR (doc = -1))"
And the option “Restrict search to these categories and tags” is set at “17”
I’m having the same problem–also as of the most recent update, and also with the same two options (“Restrict search to these categories and tags” and “Exclude these categories and tags from search”).
When I put in that code to functions.php and did a search (while having “Restrict search to these categories and tags” set to “6”), I got this:
string(348) "SELECT *, title * 5 + content + comment * 0.75 + tag * 0.75 + link * 0 + author + category * 0.75 + excerpt + taxonomy + customfield + mysqlcolumn AS tf FROM wp_relevanssi WHERE term = 'nodules' AND ((doc IN (SELECT DISTINCT(ID) FROM wp_posts WHERE post_type IN ('post','page','attachment'))) OR (doc = -1)) ORDER BY tf DESC LIMIT 500"
Yeah, looks like there’s a wee bug in the latest version.
For a quick fix, find this line in lib/search.php:
$tax_query_relation = apply_filters('relevanssi_default_tax_query_relation', 'OR');
and add after it:
if (isset($query->tax_query) && empty($query->tax_query->queries)) $query->tax_query = null;
That should make it work.
Actually, I just released version 3.1.8, which should fix this.