Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Register Search Result String Highlighting.
- *
- */
- function wps_highlight_results($text){
- if(is_search()){
- $sr = get_query_var('s');
- $keys = explode(" ",$sr);
- $text = preg_replace('/('.implode('|', $keys) .')/iu', '<strong class="search-excerpt">'.$sr.'</strong>', $text);
- }
- return $text;
- }
- add_filter('the_excerpt', 'wps_highlight_results');
- add_filter('the_title', 'wps_highlight_results');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement