Enlight searched text in wordpress search results

January 10, 2009

Many WordPress users find the search function a bit imcomplete. For exemple, it don’t automatically hightlight the searched text. Open your search.php file and find the the_title() function. Replace it with the following: echo $title; Now, just before the modified line, add this 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 style.css.... [Read the full story]