Site logo

Archived topic

Relevanssi: "Did you mean" feature

11 replies · Started by Daniel on October 3, 2018

Viewing posts 1–12 of 12

Hi Leo,

in their documentation they say, that I have to put some custom code in my searchtemplate.

When I update GP these changes are lost, I think. My question is, if I can add this anyway in a way, that I don't lose it?

Best, Daniel

No, I hoped there could be a snippet for the functions.php, which I can add into code snippets.

Hmm you'd have to ask them about that.

Their instruction doesn't seem to suggest so.

Just to close the topic, because I was also looking for it ...

The PHP code for the function mentioned above can either be added to the search via Elements or directly in the search.php (what I rather recommend) but then via a child theme.

maybe this will be of use to someone.

Thanks for sharing!

Hi Marcus,
could you explain me the way to do it by elements?
Best, Daniel

Hi there,

I am not sure where you want to place it on the search results, but you can try:

1. Create a new Hook Element.
2. Add your code:

<?php
if ( function_exists( 'relevanssi_didyoumean' ) ) {
    relevanssi_didyoumean(
    	get_search_query( false ),
        '<p>Did you mean: ',
        '</p>',
        5
    );
}
?>

3. Select the generate_before_main_content hook
4. Check execute PHP
5. Set the Display Rules to: Search Results.

Thank you David. That worked very well!

Glad to hear that!

This archived topic is closed to new replies.