📜  wordpress 高亮文本摘录 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:39.402000             🧑  作者: Mango

代码示例1
function wps_highlight_results($text){
     if(is_search()){
     $sr = get_query_var('s');
     $keys = explode(" ",$sr);
     $text = preg_replace('/('.implode('|', $keys) .')/iu', ''.$sr.'', $text);
     }
     return $text;
}
add_filter('the_excerpt', 'wps_highlight_results');
add_filter('the_title', 'wps_highlight_results');