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

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;
}

 

워드프레스 에러 기술지원 서비스 전문가에게 맡기세요
좋은 정보와 인맥을 동시에, 워드프레스 사용자 단톡방 참여하기
  • 위에서 문의 드린 후 여러가지 부분을 파악해 보았습니다.

    근데, function.php에서  [$content_list->is_latest] 이부분이 제대로 먹히지 않는 것 같습니다.

     

    제가 이해하기론 [ $content_list->is_latest ] 해당 코드가 리스트의 최신글을 불러오는 것 같은데, 현재 function.php에서는 불러와 지지 않습니다.

    kboard버전, wordpress 버전 모두 가장 최신 버전이며, KBoardBuilder.class.php 에도 최신글 리스트 생성 코드(아래코드)가 아래와 같이 들어 있습니다.

     

    위 본문내용과 아래 코드내용을 참고하여 빠른 답변 부탁드리겠습니다ㅠㅠ!!

     

     

    	/**
    	 * 최신글 리스트를 생성한다.
    	 * @param boolean $with_notice
    	 * @param array $args
    	 * @return string
    	 */
    	public function createLatest($with_notice=true, $args=array()){
    		ob_start();
    		
    		$list = new KBContentList($this->board_id);
    		
    		if(!is_array($this->board_id) && $this->board->isPrivate()){
    			if(is_user_logged_in()){
    				$list->memberUID(get_current_user_id());
    			}
    			else{
    				$list->stop = true;
    			}
    		}
    
    		$list->is_latest = true; 
    		$list->latest = $args;
    		$list->category1($this->category1);
    		$list->category2($this->category2);
    		$list->category3($this->category3);
    		$list->category4($this->category4);
    		$list->category5($this->category5);
    		$list->setSorting($this->sort);
    		$list->rpp($this->rpp);
    		$list->setDayOfWeek($this->dayofweek);
    		$list->setWithinDays($this->within_days);
    		$list->setRandom($this->random);
    		$list->setSortRandom($this->sort_random);
    		$list->getList('', '', $with_notice);
    		
    		$url = new KBUrl();
    		$url->is_latest = true;
    		$url->setBoard($this->board);
    		$url->setPath($this->url);
    		
    		$vars = array(
    			'latest' => $args,
    			'board_url' => $this->url,
    			'list' => $list,
    			'url' => $url,
    			'skin' => $this->skin,
    			'skin_path' => $this->skin->url($this->skin_name),
    			'skin_dir' => $this->skin->dir($this->skin_name),
    			'board' => $this->board,
    			'boardBuilder' => $this,
    		);
    		
    		echo $this->skin->load($this->skin_name, 'latest.php', $vars);
    		
    		return ob_get_clean();
    	}




     

좋은 정보와 인맥을 동시에, 워드프레스 사용자 단톡방 참여하기