일정 추천 이상 되면 베스트 게시판으로 가게 할 수 있나요?

안녕하세요.  케이보드 사용 할려고 하는데 궁금한점이 하나 있어서 문의 드립니다.

예시로 하는 게시판 형식이 오늘의 유머(www.todayhumor.co.kr)의 3단계 게시판 형태로 만들려고 합니다.

참고로 오늘의 유머 3단계 게시판의 구조는 다음과 같습니다.

어떤사람이 오늘의 유머 홈페이지 아무 게시판 카테고리(유머글, 유머자료, 동물게시판, 게임게시판 등등)에 글을 올리고,

추천 10개 이상이 되면 자동으로 베스트 게시판에도 처음에 작성했던 게시물과 댓글이 올라갑니다.

그리고 추천이 70개 또는 100개가 넘어가면 베스트 오브 게시판이라고 하는 게시판에 게시물과 댓글이 그대로 올라갑니다. 

이러한 3단계 구조로 된 커뮤니티 사이트 게시판을 만들려고 하는데 케이보드로도 구현이 가능한지요?

혹시 아직 안되면 요런 형태의 게시판을 만들어 주실수 있으신지 싶어서 문의 드립니다.  

좋은 정보와 인맥을 동시에, 워드프레스 사용자 단톡방 참여하기
좋은 정보와 인맥을 동시에, 워드프레스 사용자 단톡방 참여하기
  • 스레드봇님 고맙다는 말씀 전해드려야 하는데 답신이 늦었습니다.

    스레드봇님 정말 고맙습니다. 케이보드를 선택한 제 선택이 옳았던거 같습니다.

    이렇게나마 고맙다는 말씀 드리며,

    열심히 사이트 운영해서 많은 사람들에게 도움이 되도록 하겠습니다. 고맙습니다. ^^

    그리고 다음에 운영하다가 개선점이 필요 할 때 또 질의 드리겠습니다. ^^

  • 1. 올려주신 코드 중

    아래의 코드를 지우신 후에도 확인해보시겠어요? (코드가 중복됩니다.)

    add_filter('kboard_list_where', 'my_kboard_list_where', 10, 3);
    function my_kboard_list_where($where, $board_id, $content_list){
    	if($board_id == '61'){ // 실제 게시판 id로 적용해주세요.
    		$where .= " OR `board_id` IN ('20','9','24','25','26','13','14','15','17','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','45','46','47','50','51','52','53','54','55','56','57','58','59','62')";
    	}
    	return $where;
    }

     

    2. 현재 저희 블로그에 안내되어 있는 코드는

    게시글 등록 순서로 표시됩니다.

    이전 댓글에도 안내해드린 것처럼

    베스트 게시판에서 특정 조건을 만족하는 당시의 시간 순서로 표시하는 건

    저희도 연구를 해봐야 할 듯합니다.

    고맙습니다.

  • <?php 
    function theme_enqueue_styles() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
        wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array( 'parent-style' ) );
    }
    add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
    
    add_filter('kboard_list_where', 'my_kboard_list_where', 10, 3);
    function my_kboard_list_where($where, $board_id, $content_list){
    	if($board_id == '61'){ // 실제 게시판 id로 적용해주세요.
    		$where .= " OR `board_id` IN ('20','9','24','25','26','13','14','15','17','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','45','46','47','50','51','52','53','54','55','56','57','58','59','62')";
    	}
    	return $where;
    }
    
    add_filter('kboard_list_where', 'today_best_kboard_list_where', 10, 3);
    function today_best_kboard_list_where($where, $board_id, $content_list){
    	$keyword = kboard_keyword();
    	$target = kboard_target();
    	
    	if($board_id == '21'){ // 실제 적용될 베스트 게시판의 ID값으로 변경해주세요.
    		$vote = '3';
    		if($keyword){
    			$keyword = "%{$keyword}%";
    			if($target){
    				$where = "`vote`>='{$vote}' AND `{$target}` LIKE '{$keyword}' AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
    			}
    			else{
    				$where = "`vote`>='{$vote}' AND (`title` LIKE '{$keyword}' OR `content` LIKE '{$keyword}' OR `member_display` LIKE '{$keyword}') AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
    			}
    		}
    		else{
    			$where = "`vote`>='{$vote}' AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
    		}
    	}
    	
    	if($board_id == '22'){ // 실제 적용될 베스트 오브 베스트 게시판의 ID값으로 변경해주세요.
    		$vote = '5';
    		if($keyword){
    			$keyword = "%{$keyword}%";
    			if($target){
    				$where = "`vote`>='{$vote}' AND `{$target}` LIKE '{$keyword}' AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
    			}
    			else{
    				$where = "`vote`>='{$vote}' AND (`title` LIKE '{$keyword}' OR `content` LIKE '{$keyword}' OR `member_display` LIKE '{$keyword}') AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
    			}
    		}
    		else{
    			$where = "`vote`>='{$vote}' AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
    		}
    	}
    	
    	if($board_id == '61'){ // 실제 게시판 id로 적용해주세요.
    		if($keyword){
    			$keyword = "%{$keyword}%";
    			if($target){
    				$where .= "OR `board_id` IN ('20','9','24','25','26','13','14','15','17','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','45','46','47','50','51','52','53','54','55','56','57','58','59','62') AND `{$target}` LIKE '{$keyword}' AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
    			}
    			else{
    				$where .= "OR `board_id` IN ('20','9','24','25','26','13','14','15','17','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','45','46','47','50','51','52','53','54','55','56','57','58','59','62') AND (`title` LIKE '{$keyword}' OR `content` LIKE '{$keyword}' OR `member_display` LIKE '{$keyword}') AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
    			}
    		}
    		else{
    			$where .= " OR `board_id` IN ('20','9','24','25','26','13','14','15','17','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','45','46','47','50','51','52','53','54','55','56','57','58','59','62')";
    		}
    	}
    	
    	return $where;
    }
    
    add_filter('kboard_allowed_board_id', 'my_kboard_allowed_board_id1', 10, 2);
    function my_kboard_allowed_board_id1($allowed_board_id, $board_id){
    	if($allowed_board_id == '21'){ // 베스트 게시판
    		$allowed_board_id = array('21','22','61','20','9','24','25','26','13','14','15','17','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','45','46','47','50','51','52','53','54','55','56','57','58','59','62'); // 자신과 다른 게시판의 ID값을 입력
    	}
    	else if($allowed_board_id == '22'){ // 베스트 오브 베스트 게시판
    		$allowed_board_id = array('22','21','61','20','9','24','25','26','13','14','15','17','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','45','46','47','50','51','52','53','54','55','56','57','58','59','62'); // 자신과 다른 게시판의 ID값을 입력
    	}
                 else if($allowed_board_id == '61'){ // 베스트 오브 베스트 게시판
    		$allowed_board_id = array('22','21','61','20','9','24','25','26','13','14','15','17','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','45','46','47','50','51','52','53','54','55','56','57','58','59','62'); // 자신과 다른 게시판의 ID값을 입력
    	}
    	return $allowed_board_id;
    }
    
    
    
    
    add_filter('kboard_list_where', 'today_best_kboard_list_where', 10, 3);
    function today_best_kboard_kboard_list_where($where, $board_id, $content_list){
        $keyword = kboard_keyword();
        $target = kboard_target();
        
        if(in_array($board_id, array('21','22','61'))){ // 실제 적용될 게시판의 ID값으로 변경해주세요.
            $date = date('Ym01000000', current_time('timestamp')); // 이번달 시작 날짜 기준
            if($keyword){
                $keyword = "%{$keyword}%";
                if($target){
                    $where = "`date`>='{$date}' AND `{$target}` LIKE '{$keyword}' AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
                }
                else{
                    $where = "`date`>='{$date}' AND (`title` LIKE '{$keyword}' OR `content` LIKE '{$keyword}' OR `member_display` LIKE '{$keyword}') AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
                }
            }
            else{
                $where = "`date`>='{$date}' AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
            }
        }
        
        return $where;
    }
    
    
    

    스레드 봇님 고맙습니다. 또 고맙습니다. ^^

    덕분에 베스트게시판(21번)과 베오베게시판(22번)에서 검색어를 통한 검색이 됩니다만 ㅠㅠ

    위에 코드 내용이 뭐가 문제가 있는것 같습니당

     

    1. 61번 게시판(새로운글 게시판)은 검색이 안되네요 ㅠㅠ

     

    2. 베스트 그리고 베오베 게시판 시간 순서대로 정렬 코드도 짜주셔서 고맙습니다. 

    그런데 제가 설명이 미흡해서 그런지 제가 원하는 것과는 조금 다르내요 ㅠㅠ (귀찮겠지만..요것만 되면 거의 완성이니 잘 부탁드리겠습니다.)

    제가 원하는 시간 순서 정렬이란 처음에 글 쓴 순서로 정렬이 아니라, 추천 달성 조건 시점 시간 순서 정렬을 의미합니다.

    예를 들면 만약에 A라는 글 (2019년 8월 1일 작성, 추천 3개를 받은 시점 2019년 8월 15일)

                            B라는 글 (2019년 8월 7일 작성, 추천 3개를 받은 시점 2019년 8월 9일)이 있으면

    베스트 게시판(21번)에는 먼저 추천 3개 조건을 달성한 B글이 먼저 등록되고, 그 뒤에 A글이 개제되는 방식입니다. 

    마찬가지 베스트오브 게시판(22번)은 먼저 추천 5개를 달성하면 그 글이 먼저 등록 되게끔 설계가 되면 됩니다.

    바쁘신 와중에 코드 초보 중생 하나 도와주시면 고맙겠습니다. ㅠㅠ

     

    위의 코드에서 이 2가지를 만족시키는 코드를 알려주시면 고맙겠습니다. 이제 이것만 되면 웹페이지 골격이 거의 갖추어지는데

    염치 없지만 질문 드립니다.. ㅠㅠ 

  • kboard_list_where 필터 쪽 코드를 아래처럼

    하나의 함수에서 처리하도록 수정해보시겠어요?

    add_filter('kboard_list_where', 'today_best_kboard_list_where', 10, 3);
    function today_best_kboard_list_where($where, $board_id, $content_list){
    	$keyword = kboard_keyword();
    	$target = kboard_target();
    	
    	if($board_id == '21'){ // 실제 적용될 베스트 게시판의 ID값으로 변경해주세요.
    		$vote = '3';
    		if($keyword){
    			$keyword = "%{$keyword}%";
    			if($target){
    				$where = "`vote`>='{$vote}' AND `{$target}` LIKE '{$keyword}' AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
    			}
    			else{
    				$where = "`vote`>='{$vote}' AND (`title` LIKE '{$keyword}' OR `content` LIKE '{$keyword}' OR `member_display` LIKE '{$keyword}') AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
    			}
    		}
    		else{
    			$where = "`vote`>='{$vote}' AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
    		}
    	}
    	
    	if($board_id == '22'){ // 실제 적용될 베스트 오브 베스트 게시판의 ID값으로 변경해주세요.
    		$vote = '5';
    		if($keyword){
    			$keyword = "%{$keyword}%";
    			if($target){
    				$where = "`vote`>='{$vote}' AND `{$target}` LIKE '{$keyword}' AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
    			}
    			else{
    				$where = "`vote`>='{$vote}' AND (`title` LIKE '{$keyword}' OR `content` LIKE '{$keyword}' OR `member_display` LIKE '{$keyword}') AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
    			}
    		}
    		else{
    			$where = "`vote`>='{$vote}' AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
    		}
    	}
    	
    	if($board_id == '61'){ // 실제 게시판 id로 적용해주세요.
    		if($keyword){
    			$keyword = "%{$keyword}%";
    			if($target){
    				$where .= "OR `board_id` IN ('20','9','24','25','26','13','14','15','17','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','45','46','47','50','51','52','53','54','55','56','57','58','59','62') AND `{$target}` LIKE '{$keyword}' AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
    			}
    			else{
    				$where .= "OR `board_id` IN ('20','9','24','25','26','13','14','15','17','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','45','46','47','50','51','52','53','54','55','56','57','58','59','62') AND (`title` LIKE '{$keyword}' OR `content` LIKE '{$keyword}' OR `member_display` LIKE '{$keyword}') AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
    			}
    		}
    		else{
    			$where .= " OR `board_id` IN ('20','9','24','25','26','13','14','15','17','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','45','46','47','50','51','52','53','54','55','56','57','58','59','62')";
    		}
    	}
    	
    	return $where;
    }

     

    코드를 올려주실 땐  에디터의 코드 스니펫 삽입 기능을 이용 부탁드립니다.

    그렇지 않으면 코드가 이상해져서 에러 나는 코드로 바뀌거나,

    질의응답 시 의사소통에 오해와 문제가 생길 수도 있기 때문입니다.

    고맙습니다.

  • 필터를 적용해봤는데 

    검색 기능 작동이 안되네요.. ㅠ

    뭐가 잘못되었을까요...

    <?php 
    function theme_enqueue_styles() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
        wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array( 'parent-style' ) );
    }
    add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );

    add_filter('kboard_list_where', 'my_kboard_list_where', 10, 3);
    function my_kboard_list_where($where, $board_id, $content_list){
        if($board_id == '61'){ // 실제 게시판 id로 적용해주세요.
            $where .= " OR `board_id` IN ('20','9','24','25','26','13','14','15','17','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','45','46','47','50','51','52','53','54','55','56','57','58','59','62')";
        }
        return $where;
    }

    add_filter('kboard_allowed_board_id', 'my_kboard_allowed_board_id', 10, 3);
    function my_kboard_allowed_board_id($allowed_board_id, $board_id){
        if($allowed_board_id == '61'){
            $allowed_board_id = array('20','9','24','25','26','13','14','15','17','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','45','46','47','50','51','52','53','54','55','56','57','58','59','62');
        }
        return $allowed_board_id;
    }


    add_filter('kboard_list_where', 'today_best_kboard_list_where', 10, 3);
    function today_best_kboard_list_where($where, $board_id, $content_list){
        if($board_id == '21'){ // 실제 적용될 베스트 게시판의 ID값으로 변경해주세요.
            $vote = '3';
            $where = "`vote`>='{$vote}' AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
        }
        
        if($board_id == '22'){ // 실제 적용될 베스트 오브 베스트 게시판의 ID값으로 변경해주세요.
            $vote = '5';
            $where = "`vote`>='{$vote}' AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
        }
        
        return $where;
    }

    add_filter('kboard_list_orderby', 'today_best_kboard_list_orderby', 10, 3);
    function today_best_kboard_list_orderby($orderby, $board_id, $content_list){
        if(in_array($board_id, array('21', '22'))){ // 실제 적용될 게시판의 ID값으로 변경해주세요.
            $orderby = "`vote` DESC, `date` DESC"; // 추천수를 기준으로 정렬
        }
        
        return $orderby;
    }


    add_filter('kboard_allowed_board_id', 'my_kboard_allowed_board_id1', 10, 2);
    function my_kboard_allowed_board_id1($allowed_board_id, $board_id){
        if($allowed_board_id == '21'){ // 베스트 게시판
            $allowed_board_id = array('21','22','61','20','9','24','25','26','13','14','15','17','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','45','46','47','50','51','52','53','54','55','56','57','58','59','62'); // 자신과 다른 게시판의 ID값을 입력
        }
        else if($allowed_board_id == '22'){ // 베스트 오브 베스트 게시판
            $allowed_board_id = array('22','21','61','20','9','24','25','26','13','14','15','17','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','45','46','47','50','51','52','53','54','55','56','57','58','59','62'); // 자신과 다른 게시판의 ID값을 입력
        }
        return $allowed_board_id;
    }


    add_filter('kboard_list_where', 'today_best_kboard_list_where', 10, 3);
    function today_best_kboard_kboard_list_where($where, $board_id, $content_list){
        $keyword = kboard_keyword();
        $target = kboard_target();
        
        if(in_array($board_id, array('21','22','61'))){ // 실제 적용될 게시판의 ID값으로 변경해주세요.
            $date = date('Ym01000000', current_time('timestamp')); // 이번달 시작 날짜 기준
            if($keyword){
                $keyword = "%{$keyword}%";
                if($target){
                    $where = "`date`>='{$date}' AND `{$target}` LIKE '{$keyword}' AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
                }
                else{
                    $where = "`date`>='{$date}' AND (`title` LIKE '{$keyword}' OR `content` LIKE '{$keyword}' OR `member_display` LIKE '{$keyword}') AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
                }
            }
            else{
                $where = "`date`>='{$date}' AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
            }
        }
        
        return $where;
    }
     

  • 여러 개의 게시판에 적용하시려면

    올려주신 코드 중 $board_id == '21','22','61' 부분을

    in_array($board_id, array('21','22','61'))로 교체해서 확인해보시겠어요?

    고맙습니다.

  • 스레드봇님 답변 감사합니다. ^^

    1번 기능도 빨리 되었으면 좋겠습니다. 

    참고로 www.todayhumor.co.kr의 베스트, 베스트오브베스트 게시판이 추천수 10개, 100개를 기준으로 추천 달성 시간순으로 배열을 하고 있습니다.

    요걸 참고 하셔서 그 기능을 추가 해주시면 고맙겠습니다.ㅠ

    (추천 달성 시간 순서대로 안되니 베스트오브베스트나 베스트 게시판 구분의 필요성이 없네용.....ㅠ

    사실 제 웹페이지에서 이게 제일 큰건데 이게 안되니 좀...시무룩...아쉽네용 ㅠㅠ)

     

    2. 스레드봇님이 알려주신 https://www.cosmosfarm.com/threads/document/26048 코드로 funtions.php에 넣었는데...

    add_filter('kboard_list_where', 'month_best_kboard_list_where', 10, 3);
    function monthly_best_kboard_list_where($where, $board_id, $content_list){
        $keyword = kboard_keyword();
        $target = kboard_target();
        
        if($board_id == '21','22','61'){ // 실제 적용될 게시판의 ID값으로 변경해주세요.
            $date = date('Ym01000000', current_time('timestamp')); // 이번달 시작 날짜 기준
            if($keyword){
                $keyword = "%{$keyword}%";
                if($target){
                    $where = "`date`>='{$date}' AND `{$target}` LIKE '{$keyword}' AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
                }
                else{
                    $where = "`date`>='{$date}' AND (`title` LIKE '{$keyword}' OR `content` LIKE '{$keyword}' OR `member_display` LIKE '{$keyword}') AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
                }
            }
            else{
                $where = "`date`>='{$date}' AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
            }
        }
        
        return $where;
    }

    21, 22, 61번 게시판 검색기능을 살려야 해서 id에 21, 22, 61번을 넣으니 에러코드 뜨네요 ㅠㅠ

    Parse error: syntax error, unexpected ',' in /lomon/www/wp-content/themes/Avada-child/functions.php on line 67

    The site is experiencing technical difficulties.

     

    그래서 위에코드를 funtions.php에 3번 쓰고, id 하나씩 넣으니 한개 게시판만 검색기능이 활성화 됩니다.ㅠ

    코드가 중복되어서 그런건가요??

  • 안녕하세요~^^

    1. 베스트 게시판에서 특정 조건을 만족하는 게시글을 시간 순서로 표시하는 건

    저희도 연구를 해봐야 할 듯합니다.

    좋은 방법을 찾게 되면 다시 안내해드리겠습니다.

     

    2. 베스트 게시판에서 검색 기능을 동작하게 하시려면

    아래 링크를 참고해보시겠어요?

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

    고맙습니다.

  • 흐와아와아아아앙 고맙습니다. 스레드 봇님  ㅠㅠㅠㅠㅠ

    추가 코드에만 id1을 더 붙여주면 되네요 ㅠㅠㅠㅠㅠㅠㅠㅠ 흐아아아아앙아아 ㅠ

    모르니 넘 답답했는데...... 가르쳐주셔도 초보라 떠먹여주는 코드도 잘 못먹습니다. ㅠ

    덕분에 위에 코드로 베스트오브베스트, 베스트 게시판이 완성되었습니다.

    베오베, 베스트 게시판은 잘 돌아가는데

    2가지 문제점을 찾았습니다.

     

    1. 베스트(추천 3개), 베오베(추천 5개)로 알려주신 코드로 게시판을 짜놓았는데... 베스트, 베오베 게시판에 글이 올라오는 순서를 바꿀려고 합니다.

    지금은 베스트, 베오베 게시판 글 게재 순서는 추천이 가장 많은글이 게시판 제일 위에 개제되는 방식으로 됩니다.

    (예를 들면 추천 갯수가 제일 많은 글이 베스트 또는 베스트오브베스트 게시판 최상단에 게재 되고,

    방금 베스트 또는 베스트 오브 베스트 게시판으로 온 글은 동일 추천 갯수의 글중에서 최상단에 오네요.) 

     

    원하는 베스트,베오베 게시판 글 게시 순서 :

    게시판에 글이 올라올수 있는 조건이 달성 된 시간순서대로 글 게시가 되었으면 합니다.

    예를 들면, 베스트 게시판에서 최근에 추천3개 받아 베스트로 온 글은 베스트 게시판 최상단에, 그 이전에 추천 3개받아 베스트로 온 글은 새로 글이 올라올수록 순서대로 내려가게끔

    이렇게 글이 올라 오게끔 게시판을 구성 할려면 코드를 어떻게 수정 하면 좋을까요?

     

    2. 각각의 게시판 별로 kboard 비너스 웹진 왼쪽 하단에 있는 검색기에 검색어를 넣고 글을 검색하면 검색어가 들어 있는 글이 검색이 잘됩니다. 

    그런데 각각의 게시판과 연동된 게시판인 새로운글, 베스트, 베오베 게시판은 kboard 비너스 웹진 왼쪽 하단에 있는 검색기로 검색어를 입력하여 검색하면

    검색어가 들어있는 글이 검색 되는게 아니라 검색어를 넣고 검색하면 걍 새로운글, 베스트, 베오베 각 게시판에 게재되어 있는 모든글이 검색 됩니다. 

    (ex. 베스트 게시판에서 검색어를 넣어 검색해도 검색어만 들어있는 글이 검색 되는게 아니라, 걍 베스트 게시판에 있는 글 전체가 검색 됩니다.)

    이건 어떻게 수정하면 좋을까요?

    고견을 주시면 고맙겠습니다. ^^

     

  • 안녕하세요.

    Fatal error: Cannot redeclare 에러 메시지는 PHP 함수명 중복 문제입니다.

    워드프레스 필터는 여러 개 사용할 수 있지만

    PHP 함수명은 중복되면 안 됩니다.

    올려주신 코드 중 my_kboard_allowed_board_id 부분을

    my_kboard_allowed_board_id1 이런 식으로 모두 교체해서 확인해보시겠어요?

    고맙습니다.

  • 디버깅을 해보니 다음과 같은 메시가 뜨는데...이게 무슨 말일까요??

    Parse error: syntax error, unexpected '61' (T_LNUMBER), expecting ')' in /lomon/www/wp-content/themes/Avada-child/functions.php on line 59

    스레드봇님 도움 부탁 드리겠습니다. ㅠㅠ (59번째줄에 있는 61번 게시판이 문제 있다?)

     

    다시 건드려 보았는데... 이번에는 이런 메시지가 뜹니다.

    Fatal error: Cannot redeclare my_kboard_allowed_board_id() (previously declared in /lomon/www/wp-content/themes/Avada-child/functions.php:17) in /lomon/www/wp-content/themes/Avada-child/functions.php on line 60

     

     

    참고로 아래의 코드까지는 정상 작동 되고 있습니다. 현재 아래의 이 코드의 문제점은 게시글 클릭시 '이 게시글은 이동되었습니다'로 뜹니다. 

    '이 게시글은 이동되었습니다'만 안뜨면 되는데 위에 여러 게시판에서 열람 가능하게 하는 필터 적용시에는 syntax error 또는 fatal erro가 뜹니다. ㅠㅠ

    <?php 
    function theme_enqueue_styles() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
        wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array( 'parent-style' ) );
    }
    add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );

    add_filter('kboard_list_where', 'my_kboard_list_where', 10, 3);
    function my_kboard_list_where($where, $board_id, $content_list){
        if($board_id == '61'){ // 실제 게시판 id로 적용해주세요.
            $where .= " OR `board_id` IN ('20','9','24','25','26','13','14','15','17','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','45','46','47','50','51','52','53','54','55','56','57','58','59','62')";
        }
        return $where;
    }

    add_filter('kboard_allowed_board_id', 'my_kboard_allowed_board_id', 10, 3);
    function my_kboard_allowed_board_id($allowed_board_id, $board_id){
        if($allowed_board_id == '61'){
            $allowed_board_id = array('20','9','24','25','26','13','14','15','17','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','45','46','47','50','51','52','53','54','55','56','57','58','59','62');
        }
        return $allowed_board_id;
    }


    add_filter('kboard_list_where', 'today_best_kboard_list_where', 10, 3);
    function today_best_kboard_list_where($where, $board_id, $content_list){
        if($board_id == '21'){ // 실제 적용될 베스트 게시판의 ID값으로 변경해주세요.
            $vote = '3';
            $where = "`vote`>='{$vote}' AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
        }
        
        if($board_id == '22'){ // 실제 적용될 베스트 오브 베스트 게시판의 ID값으로 변경해주세요.
            $vote = '5';
            $where = "`vote`>='{$vote}' AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
        }
        
        return $where;
    }

    add_filter('kboard_list_orderby', 'today_best_kboard_list_orderby', 10, 3);
    function today_best_kboard_list_orderby($orderby, $board_id, $content_list){
        if(in_array($board_id, array('21', '22'))){ // 실제 적용될 게시판의 ID값으로 변경해주세요.
            $orderby = "`vote` DESC, `date` DESC"; // 추천수를 기준으로 정렬
        }
        
        return $orderby;
    }


     

  • 안녕하세요.

    코드 수정 후 페이지에 The site is experiencing technical difficulties. 문구가 표시된다면

    코드를 잘못 수정했을 가능성이 높습니다.

    워드프레스 디버그 모드를 활성화하시면 에러 메시지를 확인해보실 수 있습니다.

    워드프레스 에러 확인하기 - 디버그 모드 활성화 방법

    고맙습니다.

  • 코드를 삽입하니깐 웹페이지가 The site is experiencing technical difficulties. 로 뜹니다 ㅠㅠ

    저 위에코드 넣기전에 코드는 다음과 같습니다. 

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

    <?php 
    function theme_enqueue_styles() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
        wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array( 'parent-style' ) );
    }
    add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );

    add_filter('kboard_list_where', 'my_kboard_list_where', 10, 3);
    function my_kboard_list_where($where, $board_id, $content_list){
        if($board_id == '61'){ // 실제 게시판 id로 적용해주세요.
            $where .= " OR `board_id` IN ('20','9','24','25','26','13','14','15','17','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','45','46','47','50','51','52','53','54','55','56','57','58','59','62')";
        }
        return $where;
    }

    add_filter('kboard_allowed_board_id', 'my_kboard_allowed_board_id', 10, 3);
    function my_kboard_allowed_board_id($allowed_board_id, $board_id){
        if($allowed_board_id == '61'){
            $allowed_board_id = array('20','9','24','25','26','13','14','15','17','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','45','46','47','50','51','52','53','54','55','56','57','58','59','62');
        }
        return $allowed_board_id;
    }


    add_filter('kboard_list_where', 'today_best_kboard_list_where', 10, 3);
    function today_best_kboard_list_where($where, $board_id, $content_list){
        if($board_id == '21'){ // 실제 적용될 베스트 게시판의 ID값으로 변경해주세요.
            $vote = '3';
            $where = "`vote`>='{$vote}' AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
        }
        
        if($board_id == '22'){ // 실제 적용될 베스트 오브 베스트 게시판의 ID값으로 변경해주세요.
            $vote = '5';
            $where = "`vote`>='{$vote}' AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
        }
        
        return $where;
    }

    add_filter('kboard_list_orderby', 'today_best_kboard_list_orderby', 10, 3);
    function today_best_kboard_list_orderby($orderby, $board_id, $content_list){
        if(in_array($board_id, array('21', '22'))){ // 실제 적용될 게시판의 ID값으로 변경해주세요.
            $orderby = "`vote` DESC, `date` DESC"; // 추천수를 기준으로 정렬
        }


        
        return $orderby;
    }


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

     위에 코드에 스레드 봇님이 오늘 알려주신 코드를 변형해서 funtions에 넣었는데....

    코드를 삽입하니깐 웹페이지 전체가 The site is experiencing technical difficulties. 로 뜹니다 

     

    제가 array부분을 다양하게 변형해서 코드를 넣어 봐도 계속 The site is experiencing technical difficulties로 뜨네용 ㅠㅠ

    add_filter('kboard_allowed_board_id', 'my_kboard_allowed_board_id', 10, 2);
    function my_kboard_allowed_board_id($allowed_board_id, $board_id){
        if($allowed_board_id == '21'){ // 베스트 게시판
            $allowed_board_id = array('21,'61','20','9','24','25','26','13','14','15','17','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','45','46','47','50','51','52','53','54','55','56','57','58','59','62'); // 자신과 다른 게시판의 ID값을 입력
        }
        else if($allowed_board_id == '22'){ // 베스트 오브 베스트 게시판
            $allowed_board_id = array('22,'61','20','9','24','25','26','13','14','15','17','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','45','46','47','50','51','52','53','54','55','56','57','58','59','62'); // 자신과 다른 게시판의 ID값을 입력
        }
        return $allowed_board_id;
    }

     

    참고로 게시판 구조는 모든 글들은 각자의 게시판에도 뜨고,  61번 게시판(전체 새글 게시판)에도 뜨게 설계가 되어 있습니다.

     

     

  • 안녕하세요~^^

    버전이 업데이트 되면서 허가되지 않은 다른 게시판에서 게시글을 불러오는것을 차단하는 코드가 추가되었습니다.

    게시판마다 권한 설정이 다른데 게시글을 그냥 불러올 수 있다면 문제가 발생될 수 있기 때문입니다.

    아래 코드를 테마의 functions.php 파일에 추가를 해주시겠어요?

    add_filter('kboard_allowed_board_id', 'my_kboard_allowed_board_id', 10, 2);
    function my_kboard_allowed_board_id($allowed_board_id, $board_id){
    	if($allowed_board_id == '3'){ // 베스트 게시판
    		$allowed_board_id = array('3', '1', '2'); // 자신과 다른 게시판의 ID값을 입력
    	}
    	else if($allowed_board_id == '4'){ // 베스트 오브 베스트 게시판
    		$allowed_board_id = array('4', '1', '2'); // 자신과 다른 게시판의 ID값을 입력
    	}
    	return $allowed_board_id;
    }

    워드프레스 관리자 -> 테마 디자인 -> 테마 편집기 메뉴에서 functions.php 파일을 편집할 수 있습니다.

    고맙습니다.

  • 우와 우와 정말 대단하고 고맙습니다.

    기대는 안했지만 코딩을 해주시다니 케이보드를 선택 하는 이유가 역시나 있는것 같습니다. 

    웹프로그래밍이 아직은 어렵지만

    케이보드와 워드프레스와 함께 차근 차근 만들어 보겠습니다.

    뭔가 돌파구가 보이는듯 합니다.

    정말 고맙습니다. ^^ 

  • 우선, 베스트 게시판과 베스트 오브 베스트 게시판을 만들어주세요.

    워드프레스 관리자 -> 외모 -> 테마 편집기에서 functions.php 파일 하단에

    아래의 코드를 추가해보시겠어요?

    add_filter('kboard_list_where', 'today_best_kboard_list_where', 10, 3);
    function today_best_kboard_list_where($where, $board_id, $content_list){
    	if($board_id == '1'){ // 실제 적용될 베스트 게시판의 ID값으로 변경해주세요.
    		$vote = '10';
    		$where = "`vote`>='{$vote}' AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
    	}
    	
    	if($board_id == '2'){ // 실제 적용될 베스트 오브 베스트 게시판의 ID값으로 변경해주세요.
    		$vote = '100';
    		$where = "`vote`>='{$vote}' AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
    	}
    	
    	return $where;
    }
    
    add_filter('kboard_list_orderby', 'today_best_kboard_list_orderby', 10, 3);
    function today_best_kboard_list_orderby($orderby, $board_id, $content_list){
    	if(in_array($board_id, array('1', '2'))){ // 실제 적용될 게시판의 ID값으로 변경해주세요.
    		$orderby = "`vote` DESC, `date` DESC"; // 추천수를 기준으로 정렬
    	}
    	
    	return $orderby;
    }

    위의 코드에서 $board_id == '1' 부분에는 베스트 게시판 id로 적용해보세요.

    $board_id == '2' 부분에는 베스트 오브 베스트 게시판 id로 적용해보세요.

    array('1', '2') 부분에는 베스트 게시판, 베스트 오브 베스트 게시판 id로 적용해보세요.

     

    사용 중이신 KBoard 플러그인의 버전에 따라 위의 코드를 적용했을 때

    게시글 클릭 시 본문 페이지로 이동하지 않을 수도 있습니다.

    FTP로 접속해서 /wp-content/plugins/kboard/class/KBoardBuilder.class.php 파일에

    아래의 코드가 있다면 모두 찾아서 지워보시겠어요?

    if($content->board_id != $this->board_id){
    	echo '<script>window.location.href="' . $url->set('mod', 'list')->set('uid', '')->toString() . '";</script>';
    	exit;
    }

    고맙습니다.

  • 코스모스 스레드 봇님 감사합니다. ^^

    참고로 주신 링크 내용도 감사히 잘 읽어 보았습니다. 

    그치만.....

    (워드프레스 일간, 주간, 월간 베스트 게시판 만들기)링크를 참고해봤는데, 시간 기준으로 추천 카운팅후 게시판 옮기는게 아니라

    시간 기준 없이 아주 옛날에 작성한거라도 추천수 10이상이면 베스트 게시판, 

    추천수 100이상이면 베스트 오브 베스트 게시판으로 가게 설계하려면

    위에 (워드프레스 일간, 주간, 월간 베스트 게시판 만들기)링크의 코드에서 어떻게 코드를 짜야 하는지....

    코드를 짜주시면 고맙겠지만..... 염치 없는건 아닌지 걱정 되네요.

    아니면 위 링크의 코드에서 무얼 손대야 하는지

    알려 주시면 고맙겠습니다. ^^

    (문과 출신이라ㅠㅠ 코드 짜는게 너무 어려워서, 워드프레스와 코스모스 게시판 및 플러그인을 이용해

    웹을 만들려고 하지만 코드를 짜서 하는 웹 프로그래밍은 어렵네요 ㅠㅠ)

  • 안녕하세요~^^

    KBoard(케이보드) 플러그인에 내장되어 있는 필터를 활용하시면

    말씀하신 것처럼 베스트 게시판을 구성하실 수 있을 듯합니다.

     

    KBoard 플러그인으로 베스트 게시판을 만드는 방법은

    아래의 링크를 참고해보시겠어요?

    워드프레스 일간, 주간, 월간 베스트 게시판 만들기

     

    KBoard 액션과 필터는

    아래의 링크를 참고해보세요.

    https://www.cosmosfarm.com/products/kboard/hooks

    고맙습니다.

  • #커뮤니티 자동 추천글

    James Sung의 스레드

    더보기

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