I must admit that I'm not a big fan of the WordPress built-in search engine. One of its weakest features is the fact that searched text aren't highlighted in the results, so the visitor is unable to see the searched text in the context of your article.
Luckily, there's a nice hack using regular expressions to automatically highlight searched text in search results. This code has been created by Joost de Valk who blogs at www.yoast.com.
This useful code is definitely easy to use on your own blog:
Open your
search.php
file and find the following:echo $title;
Replace it with the following code:
<?php $title = get_the_title(); $keys= explode(" ",$s); $title = preg_replace('/('.implode('|', $keys) .')/iu','<strong class="search-excerpt">\0</strong>',$title); ?>
Save the
search.php
file and open thestyle.css
file. Append the following line to it:strong.search-excerpt { background: yellow...