Use get_query_var to get the search terms.
git-svn-id: http://svn.automattic.com/wordpress/trunk@1714 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
e61cfd4b02
commit
7f5ef5c1d3
|
@ -10,7 +10,9 @@ Author URI: http://rboren.nu
|
||||||
|
|
||||||
/* Highlighting code c/o Ryan Boren */
|
/* Highlighting code c/o Ryan Boren */
|
||||||
function get_search_query_terms($engine = 'google') {
|
function get_search_query_terms($engine = 'google') {
|
||||||
global $s, $s_array;
|
$search = get_query_var('s');
|
||||||
|
$search_terms = get_query_var('search_terms');
|
||||||
|
|
||||||
$referer = urldecode($_SERVER['HTTP_REFERER']);
|
$referer = urldecode($_SERVER['HTTP_REFERER']);
|
||||||
$query_array = array();
|
$query_array = array();
|
||||||
switch ($engine) {
|
switch ($engine) {
|
||||||
|
@ -38,10 +40,10 @@ function get_search_query_terms($engine = 'google') {
|
||||||
// Check the search form vars if the search terms
|
// Check the search form vars if the search terms
|
||||||
// aren't in the referer.
|
// aren't in the referer.
|
||||||
if ( ! preg_match('/^.*s=/i', $referer)) {
|
if ( ! preg_match('/^.*s=/i', $referer)) {
|
||||||
if (isset($s_array)) {
|
if (!empty($search_terms)) {
|
||||||
$query_array = $s_array;
|
$query_array = $search_terms;
|
||||||
} else if (isset($s)) {
|
} else if (isset($search)) {
|
||||||
$query_array = array($s);
|
$query_array = array($search);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -297,6 +297,7 @@ class WP_Query {
|
||||||
}
|
}
|
||||||
if (!$q['sentence']) {
|
if (!$q['sentence']) {
|
||||||
$s_array = explode(' ',$q['s']);
|
$s_array = explode(' ',$q['s']);
|
||||||
|
$q['search_terms'] = $s_array;
|
||||||
$search .= '((post_title LIKE \''.$n.$s_array[0].$n.'\') OR (post_content LIKE \''.$n.$s_array[0].$n.'\'))';
|
$search .= '((post_title LIKE \''.$n.$s_array[0].$n.'\') OR (post_content LIKE \''.$n.$s_array[0].$n.'\'))';
|
||||||
for ( $i = 1; $i < count($s_array); $i = $i + 1) {
|
for ( $i = 1; $i < count($s_array); $i = $i + 1) {
|
||||||
$search .= ' AND ((post_title LIKE \''.$n.$s_array[$i].$n.'\') OR (post_content LIKE \''.$n.$s_array[$i].$n.'\'))';
|
$search .= ' AND ((post_title LIKE \''.$n.$s_array[$i].$n.'\') OR (post_content LIKE \''.$n.$s_array[$i].$n.'\'))';
|
||||||
|
|
Loading…
Reference in New Issue