본문 바로가기

IT/워드프레스

워드프레스 BBS테마 블로그샵[Blog Shop] shop 검색시 블로그 검색과는 다르게 검색 키워드를 띄워 쓰거나, 검색 키워드 순서가 바뀌면 검색이 안되던 현상 수정

워드프레스 BBS테마 블로그샵[Blog Shop] shop 검색시 블로그 검색과는 다르게

검색 키워드를 띄워 쓰거나, 검색 키워드 순서가 바뀌면 검색이 안되던 현상 수정




1. /html/wp-content/themes/Blog_Shop/part/폴더 sub-search-shop파일 오픈


2. /* Add Query */ 와 /* List Query  */ 의 사이 소스를 삭제한다.

아래의 내용은 삭제 당할 소스


if($s_keyword){

$addQuery = "(goods_name like '%".$s_keyword."%' OR goods_detail like '%".$s_keyword."%' OR goods_description like '%".$s_keyword."%' OR goods_seo_keyword like '%".$s_keyword."%') AND";

}

elseif($s_tag){

$addQuery = "(goods_name like '%".$s_tag."%' OR goods_detail like '%".$s_tag."%' OR goods_description like '%".$s_tag."%' OR goods_seo_keyword like '%".$s_tag."%') AND";

}


if($s_startSearchPrice && $s_endSearchPrice){

$addQuery = "goods_price>= '".$s_startSearchPrice."' AND  goods_price<='".$s_endSearchPrice."' AND";

}



3.그리고 아래의 소스로 대체한다.



//서치퀄리티업//
$str = "$s_keyword";
$keyword=preg_split('/[\s,]+/', $str, -1, PREG_SPLIT_NO_EMPTY);


//print_r($str);

//echo"<br><br>";
//print_r($keyword);

//서치퀄리티업//


if($keyword[0]){
$addQuery = "(goods_name like '%".$keyword[0]."%' OR goods_detail like '%".$keyword[0]."%' OR goods_description like '%".$keyword[0]."%' OR goods_seo_keyword like '%".$keyword[0]."%') AND";
}
if($keyword[1]){
$addQuery = "(goods_name like '%".$keyword[1]."%' OR goods_detail like '%".$keyword[1]."%' OR goods_description like '%".$keyword[1]."%' OR goods_seo_keyword like '%".$keyword[1]."%') AND";
}
if($keyword[2]){
$addQuery = "(goods_name like '%".$keyword[2]."%' OR goods_detail like '%".$keyword[2]."%' OR goods_description like '%".$keyword[2]."%' OR goods_seo_keyword like '%".$keyword[2]."%') AND";
}

if($keyword[3]){
$addQuery = "(goods_name like '%".$keyword[3]."%' OR goods_detail like '%".$keyword[3]."%' OR goods_description like '%".$keyword[3]."%' OR goods_seo_keyword like '%".$keyword[3]."%') AND";
}
if($keyword[4]){
$addQuery = "(goods_name like '%".$keyword[4]."%' OR goods_detail like '%".$keyword[1]."%' OR goods_description like '%".$keyword[4]."%' OR goods_seo_keyword like '%".$keyword[4]."%') AND";
}
if($keyword[5]){
$addQuery = "(goods_name like '%".$keyword[5]."%' OR goods_detail like '%".$keyword[5]."%' OR goods_description like '%".$keyword[5]."%' OR goods_seo_keyword like '%".$keyword[5]."%') AND";
}


elseif($s_tag){
$addQuery = "(goods_name like '%".$s_tag."%' OR goods_detail like '%".$s_tag."%*' OR goods_description like '%".$s_tag."%' OR goods_seo_keyword like '%".$s_tag."%') AND";
}

if($s_startSearchPrice && $s_endSearchPrice){
$addQuery = "goods_price>= '".$s_startSearchPrice."' AND  goods_price<='".$s_endSearchPrice."' AND";
}