최신글 기간에 대해서

안녕하세요 항상 답변 친절하게 달아주셔서 감사합니다.

add_filter('kboard_list_where', 'my_kboard_list_where', 10, 3);
function my_kboard_list_where($where, $board_id, $content_list){
    if($content_list->is_latest && in_array($board_id, array('4', '7', '8'))){
        $where .= "AND `vote` >= 3";
    }
    return $where;
}

제가 일반 게시글 같은 경우는 위에 처럼 최신글을 추천3이상만 나타나게 할 수 있는데 이걸

https://www.cosmosfarm.com/threads/document/23803

에서 답변 달아주신거처럼 최신글 모아보기 id로 할려면 어떻게 해야되죠?

 

최신글모아보기 '추천3이상' '기간은 3일 안에 쓰여진 거만' 이렇게 나타내고 싶습니다.

 

 

2. 저번에 https://www.cosmosfarm.com/threads/document/23803  2번째 질문에서 알려주신대로

날짜 관련 지워도 작동이 안되네요  https://www.cosmosfarm.com/threads/document/21414에서 알려준 코드가 작동이 안되요..

일반 게시판에서는 되는데 전체게시판 코드만 적용이 안되요

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

    1. 아래의 코드를 활용해보시겠어요?

    add_filter('kboard_list_where', 'my_kboard_list_where', 10, 3);
    function my_kboard_list_where($where, $board_id, $content_list){
    	if($content_list->is_latest && is_array($board_id)){
    		foreach($board_id as $item){
    			if(in_array($item, array('4', '7', '8'))){
    				$where .= " AND `vote` >= 3 AND `date` >= date_add(now(), interval -3 day)";
    			}
    		}
    		
    	}
    
    	return $where;
    }

     

    2. 아래 링크의 코드는 별개의 문제인지요?

     https://www.cosmosfarm.com/threads/document/21414

    좀 더 자세하게 설명해주시겠어요?

    고맙습니다.

  • 우선 답변감사합니다.

    2. 일반 게시판에서는 https://www.cosmosfarm.com/threads/document/21414  코드가 작동이 되고요

     

     

    add_filter('kboard_list_where', 'week_best_kboard_list_where', 10, 3);
    function week_best_kboard_list_where($where, $board_id, $content_list){
    	
    	if($board_id == '118'){ // 실제 적용될 게시판의 ID값으로 변경해주세요.
    		$where = "`parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
    	}
    	
    	return $where;
    }

     

    처럼 위에 코드가 적용된 id 188번인 게시판에서는

     

     

    add_filter('kboard_list_date_range', 'my_kboard_list_date_range', 10, 3);
    function my_kboard_list_date_range($date, $board, $content_list){
    	$sort_date = isset($_GET['my_kboard_list_sort'])?$_GET['my_kboard_list_sort']:'';
    	
    	if($sort_date == 'week'){
    		$date['start_date'] = date("YmdHis", strtotime("-1 week", current_time('timestamp')));
    	}
    	else if($sort_date == 'month'){
    		$date['start_date'] = date("YmdHis", strtotime("-1 month", current_time('timestamp')));
    	}
    	else{
    		$date['start_date'] = date("YmdHis", strtotime("-1 year", current_time('timestamp')));
    	}
    	
    	$date['end_date'] = date("YmdHis", strtotime("now", current_time('timestamp')));
    
    	return $date;
    }

    위에 코드인 1년, 1개월, 1주일 이 작동을 안합니다.

     

    --------------------------------------------------------------------------------

    1번에서 알려주신 코드 적용 해 본 결과 제가 한 페이지에 최신글 모아보기 id5랑 id6이 있는데 6,7,8적용했더니

    이상하게 5만 적용되고 6에는 적용이 안되더라고요 왜 그런거죠?..,

     

  • 안녕하세요.

    아래의 코드는 어떤 이유로 추가하셨는지요?

    테마의 functions.php 파일에서 아래의 코드를 지우고 확인해보시겠어요?

    add_filter('kboard_list_where', 'week_best_kboard_list_where', 10, 3);
    function week_best_kboard_list_where($where, $board_id, $content_list){
    	
    	if($board_id == '118'){ // 실제 적용될 게시판의 ID값으로 변경해주세요.
    		$where = "`parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
    	}
    	
    	return $where;
    }

     

    1번에서 알려드린 코드에서 id부분은 최신글 모아보기 id가 아닌

    실제 게시판 id로 적용하신 후에 확인해보시겠어요?

    고맙습니다.

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