이전글 다음글 관련 문의

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

 

이 글을 참고하여 이전글 다음글을 update 기준값으로 설정해놓고 쓰고 있었는데요, 케이보드 업데이트 이후에 이전글 다음글이 이상하게 뜨는 상황입니다ㅠㅠ

오른쪽에 표시되는 다음글은 현재 읽고 있는 글 다음글이 제대로 표시됩니다.

문제는 왼쪽에 표시되는 이전글인데요......무조건 게시판 제일 첫글이 표시되어 뜨네요;;;

어떻게 고치는지 도와주세요ㅠㅠㅠㅠ

워드프레스 에러 기술지원 서비스 전문가에게 맡기세요
워드프레스 에러 기술지원 서비스 전문가에게 맡기세요
  • 안녕하세요~^^

    KBoard 플러그인 업데이트 시 기본 스킨의 경우 복사해서 작업하지 않으시면

    수정하신 코드가 지워질 수 있기 때문에 코드를 다시 적용해주셔야 합니다.

     

    올려주신 링크의 코드가 저희 쪽 테스트 서버에서는

    정상적으로 동작하는 것을 확인했습니다.

    실제 적용한 코드를 에디터의 코드 스니펫 삽입 기능을 사용해서 올려주시겠어요?

    고맙습니다.

  • function get_next_content_uid($board_id, $current_uid, $key, $value){
        global $wpdb;
         
        $board_id = intval($board_id);
        $current_uid = intval($current_uid);
        $key = esc_sql(sanitize_key($key));
        $value = esc_sql(sanitize_text_field($value));
         
        $where[] = "`board_id`='{$board_id}'";
        $where[] = "`uid`!='{$current_uid}'";
        $where[] = "`$key`>='{$value}'";
         
        // 휴지통에 없는 게시글만 불러온다.
        $where[] = "(`status`='' OR `status` IS NULL OR `status`='pending_approval')";
         
        $category1 = kboard_category1();
        $category2 = kboard_category2();
         
        if($category1){
            $category1 = esc_sql($category1);
            $where[] = "`category1`='{$category1}'";
        }
        if($category2){
            $category2 = esc_sql($category2);
            $where[] = "`category2`='{$category2}'";
        }
         
        $where = implode(' AND ', $where);
        $uid = $wpdb->get_var("SELECT `uid` FROM `{$wpdb->prefix}kboard_board_content` WHERE {$where} ORDER BY `{$key}` ASC LIMIT 1");
         
        return intval($uid);
    }
     
    function get_prev_content_uid($board_id, $current_uid, $key, $value){
        global $wpdb;
         
        $board_id = intval($board_id);
        $current_uid = intval($current_uid);
        $key = esc_sql(sanitize_key($key));
        $value = esc_sql(sanitize_text_field($value));
         
        $where[] = "`board_id`='{$board_id}'";
        $where[] = "`uid`!='{$current_uid}'";
        $where[] = "`$key`<='{$value}'";
         
        // 휴지통에 없는 게시글만 불러온다.
        $where[] = "(`status`='' OR `status` IS NULL OR `status`='pending_approval')";
         
        $category1 = kboard_category1();
        $category2 = kboard_category2();
         
        if($category1){
            $category1 = esc_sql($category1);
            $where[] = "`category1`='{$category1}'";
        }
        if($category2){
            $category2 = esc_sql($category2);
            $where[] = "`category2`='{$category2}'";
        }
         
        $where = implode(' AND ', $where);
        $uid = $wpdb->get_var("SELECT `uid` FROM `{$wpdb->prefix}kboard_board_content` WHERE {$where} ORDER BY `{$key}` DESC LIMIT 1");
         
        return intval($uid);
    }

    위의 코드를 function.php에 넣고

    /wp-content/plugins/kboard/skin/사용중인스킨/document.php 파일에

    $bottom_content_uid = $content->getPrevUID(); 

    를 찾아서 

    $bottom_content_uid = get_prev_content_uid($board->id, $content->uid, 'update', $content->update); 

    로 바꿨습니다.

    $top_content_uid = $content->getNextUID(); 

    이것도 

    $top_content_uid = get_next_content_uid($board->id, $content->uid, 'update', $content->update);

    이렇게 바꿨습니다

  • 안녕하세요.

    코드 상에는 별문제 없는 듯합니다.

    저희 쪽 테스트 서버에서는 이전 글도 업데이트순으로 정상적으로 표시되고 있습니다.

    저희 고객지원 쪽 이메일로 워드프레스 관리자 계정과 FTP 접속 정보를 보내주시면 점검해드리겠습니다.

    고맙습니다.

  • 제가 예전에 이전글 다음글 순서에 대한 질문을 해서 답변을 받고 코드를 적용시킨 것이 있는데요....

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

    위에 있는 코드가 문제없다면 혹시 이것과 관련이 있을까요??ㅠㅠ

  • 안녕하세요.

    KBContent 클래스의 getNextUID() 메소드 적용 시 다음 글에 항상 최신 게시글만 표시된다면

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

    아래의 코드를 찾아서

    $uid = $wpdb->get_var(apply_filters('kboard_content_next_uid_query', "SELECT `uid` FROM `{$wpdb->prefix}kboard_board_content` WHERE {$where} ORDER BY `{$order_by_sort}` DESC LIMIT 1", $this, $where, $sorting, $order_by_sort, $category1, $category2));

    아래의 코드로 교체해보세요.

    $uid = $wpdb->get_var(apply_filters('kboard_content_next_uid_query', "SELECT `uid` FROM `{$wpdb->prefix}kboard_board_content` WHERE {$where} ORDER BY `{$order_by_sort}` ASC LIMIT 1", $this, $where, $sorting, $order_by_sort, $category1, $category2));

    해당 버그는 업데이트에 반영하도록 하겠습니다.

    고맙습니다.

  • 문제 해결했습니당!!

    감사해요♡♡♡♡♡

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