How to highlight search results?
Put the following code into your content loop:
$keys = explode(" ", $s); $content = get_the_content( '<span>'.__( 'Read more', 'mytextdomain' ).'</span>' ); $content = preg_replace('/('.implode('|', $keys) .')/iu', '<span class="search-excerpt">\0</span>', $content); echo $content;
Add to your style.css file:
.search-excerpt { background-color: yellow; color: black; }
Resource:
http://www.wpbeginner.com/wp-tutorials/how-to-highlight-the-search-terms-in-results-in-wordpress/