kboard_list_where 필터의 결과와 sql 쿼리 돌렸을때 리스트가 다릅니다

1. 정확한 제품 또는 플러그인 이름

KBoard 

 

2. 상세 내용

업로드시 옵션 필드(옵션키 : cate01) 체크박스로 여러개를 선택하고 여러개 카테고리를 검색하기 위해 코드를 수정중입니다.

url 은 ?cate01=소설,시%2F에세이 이렇게 GET param으로 넘기고 cate01이 있을시 아래와 같이 kboard_list_where 필터가 적용되도록 하고있습니다.

db에서 SQL 쿼리문으로 동일하게 검색시 원하는 리스트로 결과가 나오지만

filter에 동일하게 쿼리문을 넣어도 결과가 상이하게 나옵니다.

total 값도 다르게 나옵니다.

add_filter('kboard_list_where', 'onego_kboard_list_where', 10, 3);
function onego_kboard_list_where($where, $board_id, $content_list)
{
	global $wpdb;
	if ($board_id == 9) {
		$cate01 = isset($_GET['cate01']) && $_GET['cate01'] != '' ? urldecode($_GET['cate01']) : '';
		if ($cate01 != '') {
			$cate01_arr = explode(',', $cate01);
			$meta_key = 'cate01';
			$where = "`{$wpdb->prefix}kboard_board_content`.`board_id`='9' AND (`{$wpdb->prefix}kboard_board_content`.`status` IS NULL OR `{$wpdb->prefix}kboard_board_content`.`status`='' OR `{$wpdb->prefix}kboard_board_content`.`status`='pending_approval')";
			$where .= " AND (`option_key`='{$meta_key}')";
			$where .= " AND (";
			$cate = [];
			foreach ($cate01_arr as $arr) {
				array_push($cate, "`option_value` = '{$arr}'");
			}
			$where .= implode(' OR ', $cate);
			$where .= ")";
			$where .= " GROUP BY `{$wpdb->prefix}kboard_board_option`.`content_uid`";
		}
	}
	return $where;
}

 

SELECT `wp_kboard_board_content`.`uid`
FROM `wp_kboard_board_content` LEFT JOIN `wp_kboard_board_option` ON `wp_kboard_board_content`.`uid`=`wp_kboard_board_option`.`content_uid`
WHERE `wp_kboard_board_content`.`board_id`='9' AND (`wp_kboard_board_content`.`status` IS NULL OR `wp_kboard_board_content`.`status`='' OR `wp_kboard_board_content`.`status`='pending_approval') AND (`option_key`='cate01' ) AND (`option_value` IN('시/에세이') ) GROUP BY `content_uid`
ORDER BY `wp_kboard_board_content`.`date` DESC

 

kboard_list_where 필터 통해서 간단한 옵션 키로 테스트해보아도 sql 쿼리문이랑 결과가 다 다르게 나오네요.. 이런적이 없었는데 해결방법 부탁드리겠습니다..

 

3. 확인 가능한 상세 페이지 주소

 

 

4. 수정한 코드 내역 (있다면)

 

 

워드프레스 에러 기술지원 서비스 전문가에게 맡기세요
워드프레스 에러 기술지원 서비스 전문가에게 맡기세요
워드프레스 에러 기술지원 서비스 전문가에게 맡기세요