You do wish to Enlight searched text in your blog’s search results. To do so, simply open your theme’s search.php file and then find the the_title() function and replace it with:
1 | echo $title; |
And now just before the line you modified, add this code of lines:
1 2 3 4 5 6 7 | <?php $title = get_the_title(); $keys= explode(" ",$s); $title = preg_replace('/('.implode('|', $keys) .')/iu', '<strong class="search-excerpt">\0</strong>', $title); ?> |
Once done, now open style.css and append the following line to it:
1 | strong.search-excerpt { background: yellow; } |
Snippet Source/Credit: Yoast