Skip Navigation

[Resolved] Relevanssi settings not applied

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Our next available supporter will start replying to tickets in about 5.14 hours from now. Thank you for your understanding.

This topic contains 6 replies, has 2 voices.

Last updated by Minesh 1 year, 2 months ago.

Assigned support staff: Minesh.

Author
Posts
#1776601

Hi,

Is it possible that some Relevanssi settings are not applied when using Toolset View's search?

We created a search that seems to work fine, but the Extract and highlight settings of Relevanssi, where we can highlight the searched words in the results doesn't work.

I do see in the url that the wpv_post_search string with the searched words is there and is carried to the next page if we click on a result, which I assumed is needed for that functionnality... But no words is highlighted either in the result or the opened page after a click on the result.

I see in the Relevanssi settings that for the title, "the_title()" must be replaced by "relevanssi_the_title()"... Does Views do it automatically, or we need to do it manually? Where do we do that?

Also, for the document, we must "add an additional parameter highlight to the outcoming links" and that "Relevanssi should add it automatically"... Is there something there that we need to do?

Thank you.

P.S. You can see an example of the search form in that page: hidden link

#1778209

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Can you please share few keywords that I should use to make a search and that should be highlighted within the title - correct?
If yes:

Please share access details as well so that I can look at it.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#1779705

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ok thank you.

There are two different things:
1) hidden link
Returns the title for post $post_id. Use this function to show highlighted titles ($post->highlighted_title). If there’s no highlighting in the title, the basic title is displayed.
And
2) hidden link
This function will take a string and a search query, and returns the string with all the words of the search query highlighted. The search query will be tokenized, so stopwords and small words are not highlighted. The highlighting method is the one you’ve specified in the Relevanssi settings.

Which method you want to apply. As for now, it seems you want to highlight the search keyword in the title displayed as results - correct?

in addition to that, it seems that the user you shared seems no right to edit the "Custom Code" section of Toolset. If I try to edit, it shows the error.

Can you please send me FTP access details so that I can access the source file and add the require code.

I have set the next reply to private which means only you and I have access to it.

#1780069

This is strange, since I'm an admin... And I DO have access to the Custom Code section of Toolset (I even created some functions there)...

I saw the Relevanssi documentation you refer to, I just don't know where to change it... I guess in functions.php...

I've changed the settings to enable permalinks, so the new url of the page is hidden link

I've also switched my account to English if it can help you.

Unfortunately, I'm not the owner, so I can't give you FTP access, but I have WP File Manager installed (that you can see in the left menu), so you should be able to do what you want/need with it.

To answer your question, I want the term hightlighted in the title, but also in the extract and if possible page that is displayed after we click a result (the wpv_post_search url parameter that is transfered to the page should allow that...).

Thank you.

#1780175

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please check now: hidden link

I've performed the search usingn the keyword: puissance

And I've added the following CSS code to your view's "Templates for this View" section's CSS Editor:

mark {
  background-color: yellow !important;
}

The search keyword is highlighted with yellow color background.

And I've alter the code you added as given under:

add_shortcode('show_field_with_limit', 'func_limit_field_length');
 function func_limit_field_length($atts, $content = '') {
    $content = wpv_do_shortcode($content);
    $length = (int)$atts['length'];
   
    if (strlen($content) > $length) {
        $content = substr($content, 0, $length) . '…';
        
    }
    $content = relevanssi_highlight_terms($content, $_GET['wpv_post_search']);
   
    // Strip HTML Tags
   // $content = strip_tags($content);
    
   
    return $content;
}

As the title displayed using the above shortcode, I've added the following line of code:

$content = relevanssi_highlight_terms($content, $_GET['wpv_post_search']);

Can you please confirm it works as expected now.

#1780215

Great! Yes, it works as expected!

It's strange that we need to specify CSS for the mark tag... I can see that originally it's ok, but gets overwritten a couple of times...

I just need to figure out how to do that for the article when we click on the result (should work, since it has the same url parameter).

Thank you.

#1780229

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Great - good to know that solution I shared help you to resolve your issue.

Please feel free to mark resolve this ticket and open a new ticket and assign it to me if you will require further help with your new question.