How To Highlight Search Results In WordPress
You can highlight the search result for your users/visitors, and help them find the related content more quickly and easily. This simple tutorial will help you along.
Note: Do take backup of the file you try this.
01. Replace the_exerpt() code in search.php file with:
echo $ excerpt;
02. Now just below the replaced code add these lines:
$ excerpt = get_the_excerpt();
/> $ keys = explode(" ",$ s);
/> $ excerpt = preg_replace('/('.implode('|', $ keys) .')/iu', '<strong class="search-excerpt"></strong>', $ excerpt);
03. Edit the class .search-excerpt as you want your highlight to look.
This concludes this simple and useful tutorial. Hope you like it.