Need help fine tuning the Did you mean feature
-
Hi,
Thanks for this great plugin. I’ve only now realized that it has the “Did you mean?” feature, and I’m trying to implement it on a free version (hobby site). Mine is a pronunciation dictionary, and as is common for online dictionaries, I’ve set Relevanssi to (1) redirect to the word when there’s (only one) perfect match; (2) list alternative words when there are more than one match; and (3) 404 with “Your search didn’t find anything” when there’s no match at all.
I’ve managed to add the snippet to create the shortcode for the Did You Mean functionality, but I’m having 2 issues.
First, I’m having a hard time adding the filter to change the number of hits a successful search needs to have to be considered as alternative. Currently, only misspelled searches for words that would return 3 or more hits are properly showing alternatives. So I’m trying to add the filter to actually reduce that number, instead of increasing it, as having only 1 hit would be the case with 95% of my posts.
add_filter( 'relevanssi_get_words_having', function() { return 1; } );
I tried adding it right before and right after the shortcode snippet in the
functions.php
, but it changed nothing.Do I also need to change the line that invokes the shortcode in the search results
index.php
file? Sorry if this is too basic, but though familiar with coding to add snippets, I’m not a developer.The second issue is that, for those cases where the DYM is successfully added to the results page, I’m seeing it return twice the same line, with the same URL. That URL is the search results page with all the hits for the successful term. So if I search for
tho
it give me back:Você quis dizer: to? Você quis dizer: to?
Where
to
is actually the URL where you find matches for the termto
as well as 5 expressions such ashave to
,next to
etc. Ideally, I’d have 6 lines, each pointing to the end URL of each of these terms and phrases.Thank you in advance for your time and any help will be much welcome.
EDIT: I should add that I’ve set search logging a few years back, so I have enough terms already logged. Example of searches that are not returning:
The page I need help with: [log in to see the link]
- The topic ‘Need help fine tuning the Did you mean feature’ is closed to new replies.