Relevanssi Custom Code

Hi!

I am implementing Relevanssi premium into one of the sites.

To get the “Did you mean” spelling correction functionality, it say that a code needs to be added to the search result template, preferably before the have_posts() check:

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

I know that I need to copy a file into the same path in the Child theme. Is it the _index.php from the global folder? If so, I have a bit of trouble identifying the exact place where to place the Relevanssi code. Could you give me a hand here? Thanks!

Thanks!

Hi Misho,

You identified the file for the search result page correctly as we do not have a specific template for that and it uses the same logic we use for other listing pages such as blog page.

Now regarding the third party plugin I am not sure how it should work and what is the functionality, but if you want to make sure that the code will be executed please add your code before: (Line 25)

<?php if ( $condition ) : ?>

The reason behind that is, the $condition is false when you have a search page, so you can add a code like the one below just before that line:

<?php 
  if ( is_search() ) {
    // Add your custom code
  }
?>

The code above checks if the page is a search page and then you can replace // Add your custom code with your custom code.

Needless to say that you need to copy the file into your child theme using the method below:

If you need more information about Child Theme you can check the resource below:

Please kindly consider that there is no guarantee the code you have will work as it is a third-party plugin code and outside of our support scope to delve into details of that and it will be considered as customization.

Thank you.

It worked nicely.

Thanks @christopher!

You’re most welcome, @Misho.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.