Plugin Author
Ajay
(@ajay)
Thanks for the rating and review.
The highlight search results is on the charts. If my testing goes as planned, I should have this in the next release.
im also interested in this!
make sure that in the next version the plugin also highlight the title too and not just the content text
thanks
+1
any progress on this feature?
Plugin Author
Ajay
(@ajay)
No progress on this feature yet. Due to time constraints, my current focus on plugins has been on Top 10 and Contextual Related Posts.
Better Search needs a massive rewrite to make it more extendable and for additional features like highlighting text.
It’s easy. You only have to make a few modifications to the function get_bsearch_results in better-search.php
After the following line:
$output .= get_bsearch_header( $search_query, $numrows, $limit );
Add:
$search_query = preg_quote($search_query, '/');
$keys = explode(" ",$search_query);
Modify $output for $post_title as follows:
$post_title = get_the_title( $search->ID );
$post_title = preg_replace('/('.implode('|', $keys) .')/iu', '<span style="background:#ffc;"></span>', $post_title);
$output .= '<h2><a href="'.get_permalink( $search->ID ).'" rel="bookmark">'.$post_title.'</a></h2>';
Modify $output for the excerpt as follows:
$excerpt = get_bsearch_excerpt( $search->ID, $bsearch_settings['excerpt_length'] );
$excerpt = preg_replace('/('.implode('|', $keys) .')/iu', '<span style="background:#ffc;"></span>', $excerpt);
$output .= '<span class="bsearch_excerpt">' . $excerpt . '</span>';
Plugin Author
Ajay
(@ajay)
jtkeisers, thanks for the code. I’ll implement this and test it out.
Does the suggested code work?
Plugin Author
Ajay
(@ajay)
I believe it works for jtkeisers. You’ll need to edit your file and give it a shot. I haven’t had a chance to test this.
Plugin Author
Ajay
(@ajay)
This feature has been implemented in v2.0.0