apply_filters( 'relevanssi_didyoumean_url', string $url, string $query, string $suggestion )
Filters the Did you mean suggestion URL.
Parameters
$url
(string) The URL of the suggestion.
$query
(string) The search query.
$suggestion
(string) The suggested search query.
More information
When Relevanssi has chosen a suggestion, the URL of the link passes through this filter hook. Relevanssi generates the URL by taking the value from get_bloginfo( 'url' )
and adding the s
parameter to it. If you need to add further parameters to the URL, like a post_type
parameter, you can do it here:
add_filter( 'relevanssi_didyoumean_url', 'rlv_add_dym_parameters' ); function rlv_add_dym_parameters( $url ) { return add_query_arg( 'post_type', 'product', $url ); }
Using add_query_arg()
is a good way to do to add parameters. Note that for more complicated parameters, you need to urlencode()
the parameters.
To filter the whole suggestion, you can use relevanssi_didyoumean_suggestion
.