특정 게시판의 베스트 게시판 생성

게시판아이디  1,2 의 베스트 게시판을 아이디 3(베스트 오브 베스트 100)로 만들려고 합니다.

아래와 같이 테마편집기로 올리면 될듯 해서 한번 물어보려고 합니다. 

 

두번쨰로 해당사항을 FTP를 통해서 파일교체로 진행하는게 더안전하단 생각을 합니다. 테마편집기 써먹다가 홈페이지 날려 먹은적이 있어서요

 

 /wp-content/themes/사용중인테마/functions.php 에다가 아래사항을 그대로  넣으면 되는건가요 아니면 어떤걸 빼고 넣나요?

이렇게 하면 오류가 있어도 원상복구 후 코드 새로 짜는것 외에는 오류는 없나요?

 

add_filter('kboard_list_where', 'my_kboard_list_where', 10, 3);
function my_kboard_list_where($where, $board_id, $content_list){
	if($board_id == '3'){
		$vote = '10';
		$where = "`board_id` IN ('1', '2') AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
	}
	if($board_id == '4'){
		$vote = '100';
		$where = "`board_id` IN ('1', '2') 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')))
		$orderby = "(`vote`) DESC, `date` DESC"; 
	}
	
	return $orderby;
}

코드에 아직 안익숙한데 이렇게 질문에 답변해주셔서 항상 고맙습니다. 

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

    코드를 테마의 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');
    	}
    	else if($allowed_board_id == '4'){
    		$allowed_board_id = array('4', '1', '2');
    	}
    	return $allowed_board_id;
    }

     

    코드를 추가하거나 편집하실 땐 디버그 모드를 활성화하고 작업해주세요.

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

    고맙습니다.

  • Twenty Nineteen, sixteen을 연습용으로 쓰고 있는데 안되네요. 해당 테마를  사용중에 고치려하면 치명적 에러를 점검하기위해 사이트와 통신할수 없습니다. 원래대로 복구한다는 내용이 뜨고 직접 ftp로 접속해서 고치니 접속하니 사이트 자체가 터짐니다. 코딩을 잘못했나 돌아보니 이때까지 테마편집기로 뭐건드리면 다 안되던 기억이 있어서 일간, 월간 베스트 포스트 올려주신걸 게시판 아이디만 바꿔서 올려보았는데 안되더군요. 음.. 아무래도 테마가 보호같은게 걸려서 그런게 아닌가 싶은데 기본으로 주어진 테마도 그래서 안되는 경우가 있나요? 아니면 따로 베스트 게시판 구현 방안이 있나요?

     

    Error Log Monitor

    Parse error: syntax error, unexpected '}', expecting end of file in /jungsul1004/www/wp-content/themes/twentysixteen/functions.php on line 579

     

    -----------------추가한 코드--

    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 == '10'){
            $allowed_board_id = array('10', '6', '7');
        }

        return $allowed_board_id;
    }

    add_filter('kboard_list_where', 'my_kboard_list_where', 10, 3);
    function my_kboard_list_where($where, $board_id, $content_list){
        if($board_id == '10'){
            $vote = '10';
            $where = "`board_id` IN ('6', '7') 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('10')))
            $orderby = "(`vote`) DESC, `date` DESC"; 
        }
        
        return $orderby;
    }

    마지막 줄 }가 579입니다

     

  • 안녕하세요.

    올려주신 코드를 확인해보니

    코드를 잘못 수정하신 듯합니다.

    올려주신 코드 중 아래의 코드를 찾아서

    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('10')))
    		$orderby = "(`vote`) DESC, `date` DESC";
    }
    
    return $orderby;
    }

    아래의 코드로 교체해서 확인해보시겠어요?

    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('10'))){
    		$orderby = "(`vote`) DESC, `date` DESC";
    	}
    	return $orderby;
    }

    코드 수정 시 중괄호의 열고 닫힘을 잘 확인해주셔야 할 듯합니다.

    고맙습니다.

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