apply_filters( 'relevanssi_didyoumean_suggestion', string $suggestion )

Filters the complete Did you mean suggestion.


(string) The complete suggestion HTML code.

More information

This is the final filter hook in the Did you mean process, in both free and Premium. This hook filters the complete HTML code of the suggestion:

<p>Did you mean: <a href="http://loyang.local?s=lore">lore</a></p>

If there are any adjustments required for the HTML element, this is the right place for them. For example to add a class to the link, you could do:

add_filter( 'relevanssi_didyoumean_suggestion', 'rlv_add_some_class' );
function rlv_add_some_class( $suggestion ) {
  return str_replace( '<a ', '<a class="dym_suggest" ', $suggestion );

If you just want to adjust the URL, it’s easier to use relevanssi_didyoumean_url.

If you are using post part targeting, those targeted queries look bad in the visible Did you mean suggestions. If you want to remove them from the user-visible suggestion but keep them in the URL so they remain in use, you can do this:

  function( $suggestion ) {
    return preg_replace( '/{.*?}/', '', $suggestion );