Skip Navigation

[Resolved] Custom Search + Relevanssi

This support ticket is created 7 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 5 replies, has 2 voices.

Last updated by randallH-3 7 years, 2 months ago.

Assisted by: Luo Yang.

Author
Posts
#492250
Screen Shot 2017-02-22 at 2.55.14 PM.png
Screen Shot 2017-02-22 at 2.52.15 PM.png
Screen Shot 2017-02-22 at 2.52.09 PM.png
Screen Shot 2017-02-22 at 2.48.31 PM.png

Tried using Relevanssi for searches.

Used the custom excerpt to show where is the searched term but it is not highlighted.

Attached a screenshot of the archive cell, relevanssi settings and the search results page.

Does [wpv-post-excerpt] use the_excerpt() function? or something else? What could be a possible way to fix this?

Thanks!

#492258

Dear randall,

Thanks for the details, I am trying to duplicate same problem, will feedback if there is anything found

#492275

I can duplicate same problem, the relevanssi plugin only apply highlight settings when you are using the wordpress built-in search page, for example:
hidden link

In your case, I suggest you create another new shortcode for it, for example, there is a searhbox in the parameter search form:
[wpv-filter-search-box]
we can use relevanssi_highlight_terms() to highlight the specific text.

1) add below codes into your theme/functions.php:

function highlight_keyword_func($atts, $content) {
	$content = do_shortcode($content);
	if(isset($_GET['wpv_post_search'])){
		$content = relevanssi_highlight_terms($content, $_GET['wpv_post_search']);
	}
	return $content;
}
add_shortcode( 'highlight-keyword', 'highlight_keyword_func' );

2) wrap those text which need to be highlighted with above shortcode, for example:

[highlight-keyword][wpv-post-excerpt][/highlight-keyword]
#492928
Screen Shot 2017-02-23 at 1.30.52 PM.png
Screen Shot 2017-02-23 at 1.30.37 PM.png

Hi Luo,

Is it still not working on the search result page itself, but it is working when you click the link of the post.

You will see the search from the rightmost menu of: hidden link

See the attached screenshots.

Thanks!

#492973

Since you are using wordpress built-in search form, the URL parameter name is "s", so you will need to modify the PHP codes as below+:

function hightlight_keyword_func($atts, $content) {
	$content = do_shortcode($content);
	if(isset($_GET['s'])){
		$content = relevanssi_highlight_terms($content, $_GET['s']);
	}
	return $content;
}
add_shortcode( 'hightlight-keyword', 'hightlight_keyword_func' );

and use above shortcode like this:

[hightlight-keyword][wpv-post-excerpt][/hightlight-keyword]

It will be able to search in the text of [wpv-post-excerpt], find and hightlight the keyword

#493469

Awesome! Thanks Luo!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.