relevanssi_where

apply_filters( 'relevanssi_where', string $query_restrictions )

This filter is the Relevanssi equivalent to posts_where and filters the WHERE part of the Relevanssi MySQL query.

Parameters

$query_restrictions
(string) The restrictions to the Relevanssi search MySQL query.

More information

When Relevanssi does a search query, Relevanssi uses a custom MySQL query that fetches data from the wp_relevanssi database table. If you want to add custom filtering to those queries, you can use this filter hook to add WHERE restrictions to the query.

If your restrictions require other database tables, you can use relevanssi_join to JOIN in the tables, much like you would do with posts_join.

When using this filter hook, the best way to implement the restrictions is to limit the post IDs included in the search. The post ID is not in the ID column: the column’s name is doc. So, your restrictions should look like this:

AND doc IN ( SELECT ID FROM wp_posts WHERE post_author = 1 )

This query would restrict the Relevanssi searches to post_author 1.

Examples