Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function wpse66815_search_query_string( $wp_query ) {
- if (!is_admin() && is_search()) {
- //print_r($search);
- global $wp_query,$wpdb;
- // get search term
- $search_term = $wp_query->query_vars['s'];
- //print_r($search_term);
- // specify string we'll use to replace
- $replace_var = 'TL';
- // find matches for that string
- preg_match_all("/{$replace_var}(?:[^0-9]*)(\d+)/i", $search_term, $out);
- // if there's no matches, return the normal search
- if ( empty($out[0]) )
- return $wp_query;
- // find/generate the search term with the replacement
- $modified_search_term = preg_replace(
- "/{$replace_var}(?:[^0-9]*)(\d+)/i"
- ,"{$replace_var}-$1"
- ,$search_term
- );
- // combine both the regular and modified search term
- $new_search[] = $search_term;
- $new_search[] = $modified_search_term;
- //print_r($new_search);
- // set $search equal to results
- $wp_query->query_vars['s'] = implode(' ',$new_search);
- //print_r($search);*/
- }
- return $wp_query;
- }
- add_filter('relevanssi_modify_wp_query', 'wpse66815_search_query_string');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement