apply_filters( 'relevanssi_add_highlight_and_tracking', bool $add_highlight_and_tracking, WP_Post $link_post )
This filter hook controls whether Relevanssi adds the highlighting and click tracking parameters to permalinks.
Parameters
$add_highlight_and_tracking
(bool) If true
, add the parameters to the permalink.
$link_post
(WP_Post) The post object for the permalink target post.
More information
This filter hook is used in the relevanssi_permalink()
function. The function is hooked to the permalink filters and adds the Relevanssi highlight and click tracking parameters to the permalink. By default, this happens in the following circumstances:
- It’s a search query (
is_search()
is true). - If it’s an admin query, the
relevanssi
orrlvquery
parameter istrue
. $link_post
has therelevance_score
property.
The last one, in particular, isn’t always true, even when the parameters should be added. This filter hook can force the parameters to the links in all cases. The simplest solution is this:
add_filter( 'relevanssi_add_highlight_and_tracking', '__return_true' );
This snippet will force all links to have the parameters. This will likely make them appear in places they shouldn’t, so more finesse may be required.