Highlight search-result

If you want to make it easier for your users that are using the serach-function, you can highlight the word they searched on. All changes goes in search.php.

Edit the class .search-excerpt as you want your highlight to look!

Code Snippet:

// Replace the_exerpt() with:
$excerpt = get_the_excerpt();
$keys = explode(" ",$s);
$excerpt = preg_replace('/('.implode('|', $keys) .')/iu', '<strong class="search-excerpt">\0</strong>', $excerpt);
echo $excerpt;

Posted in Pure hacks