hightlight search results
This commit is contained in:
parent
c9354c5f2e
commit
e75c9ccfdc
5 changed files with 37 additions and 8 deletions
|
|
@ -384,3 +384,15 @@ function kit_widgets_init() {
|
|||
|
||||
}
|
||||
add_action( 'widgets_init', 'kit_widgets_init' );
|
||||
|
||||
# Highlight query in search results
|
||||
|
||||
function kit_highlight_results($text){
|
||||
if(is_search()){
|
||||
$sr = get_query_var('s');
|
||||
$keys = explode(" ",$sr);
|
||||
$text = preg_replace('/('.implode('|', $keys) .')/iu', '<strong class="tx-indexedsearch-redMarkup">'.$sr.'</strong>', $text);
|
||||
}
|
||||
return $text;
|
||||
}
|
||||
add_filter('the_excerpt', 'kit_highlight_results');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue