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!
Dear randall,
Thanks for the details, I am trying to duplicate same problem, will feedback if there is anything found
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]
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!
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