최신글 지정등록일 순으로 나오게 하는 방법이 있을까요?

1. 상세 내용

kboard 최신글을 제가 지정한 등록일 순으로 나오게 하고 싶은데 방법이 있을까요? 

제가 찾아보았을 때 https://www.cosmosfarm.com/threads/document/27474 해당 글이 제가 원하는 기능을 재현하려고 하신 것 같은데요!

해당 글에서 알려주신 코드를 적용하면 작동되지 않아  $board_id == '2' 와 $content_list->is_latest 를 따로 적용시켜 보았는데요.

이 경우, $board_id == '2' 하나만 적용 했을 때는 해당 기능이 작동이 됐지만

$content_list->is_latest 하나만 적용했을 때는 작동하지 않습니다.

해당 원인이 무엇일까요?

 

2. 코드 내역 

add_filter('kboard_list_from', 'my_kboard_list_from', 10, 3);
function my_kboard_list_from($from, $board_id, $content_list){
	global $wpdb;
	if($content_list->is_latest && $board_id == '2'){
		$from .= " LEFT JOIN `{$wpdb->prefix}kboard_board_option` ON `{$wpdb->prefix}kboard_board_content`.`uid`=`{$wpdb->prefix}kboard_board_option`.`content_uid`";
	}
	return $from;
}

add_filter('kboard_list_where', 'my_kboard_list_where', 10, 3);
function my_kboard_list_where($where, $board_id, $content_list){
	global $wpdb;
	$option_key = 'select_date';
	if($content_list->is_latest && $board_id == '2'){
		$where .= " AND (`option_key`='{$option_key}')";
	}
	return $where;
}

add_filter('kboard_list_orderby', 'my_kboard_list_orderby', 10, 3);
function my_kboard_list_orderby($orderby, $board_id, $content_list){
	global $wpdb;
	if($content_list->is_latest && $board_id == '2'){
		$orderby = "`{$wpdb->prefix}kboard_board_option`.`option_value` DESC";
	}
	return $orderby;
}

 

워드프레스 에러 기술지원 서비스 전문가에게 맡기세요
워드프레스 에러 기술지원 서비스 전문가에게 맡기세요
좋은 정보와 인맥을 동시에, 워드프레스 사용자 단톡방 참여하기