그누프레스 위젯 질문드립니다! 채택완료

혹시 인기글만 뽑아 위젯으로 만들어낼순 없을까요? 이기능만 있으면 정말 좋겠는데.. 방법이 없을까 싶습니다.

답변 2개

채택된 답변
+20 포인트

워프자체에 인기글이 있을텐데 찾아보세요 ~ 다양한 스킨들이 있고 유료도 많이 있을거에요 ㅎ

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

그누프레스에서 인기글을 뽑아내려면 원본소스를 고쳐야 합니다.

 

고쳐서 하실려면

 

/gnupress.php 에서

 

470번째 줄

 

$cache_file = $cache_file_path."/cache/latest-{$bo_table}-{$skin_dir}-{$rows}-{$subject_len}.php"; 

 

이렇게 되어 있는것을 아래와 같이 고칩니다.

 

Copy
$cache_file = apply_filters('gc_latest_cache_filename', $cache_file_path."/cache/latest-{$bo_table}-{$skin_dir}-{$rows}-{$subject_len}.php", $cache_file_path, $bo_table, $skin_dir, $rows, $subject_len);

 

 

 

513번째 줄

 

$sql = $wpdb->prepare("select * from {$g5['write_table']} where bo_table = '%s' and wr_parent = 0 order by wr_num limit 0, %d ", $bo_table, $rows); 

 

이렇게 되어 있는것을 아래와 같이 고칩니다.

 

Copy
$sql = $wpdb->prepare("select * from {$g5['write_table']} where bo_table = '%s' and wr_parent = 0 order by wr_num limit 0, %d ", $bo_table, $rows);            $sql = apply_filters('gc_get_latest_sql', $sql, $g5['write_table'], $bo_table, $rows);

 

 

 

그런 다음 사용하는 테마 functions.php 에

아래 코드를 넣습니다.

 

 

Copy
add_shortcode( 'gnucommerce_board_custom_latest', 'cs_board_custom_latest' ); function cs_board_custom_latest($attr=array()){    global $gnupress;        $content = '숏코드가 지정되어 있지 않습니다.';    add_filter('gc_latest_cache_filename', 'cs_set_cache_filename', 10, 6 );    add_filter('gc_get_latest_sql', 'cs_replace_latest_sql', 10, 4 );     $attr['cache_time'] = 0.0001;   //쿼리 캐시 시간 지정 1은 1시간     if(method_exists($gnupress, 'g5_latest_shortcode')){        $content = $gnupress->g5_latest_shortcode($attr);    }     remove_filter('gc_latest_cache_filename', 'cs_set_cache_filename' );    remove_filter('gc_get_latest_sql', 'cs_replace_latest_sql');     return $content;} function cs_set_cache_filename($file_name, $cache_file_path, $bo_table, $skin_dir, $rows, $subject_len){     $file_name = $cache_file_path."/cache/latest-hot-{$bo_table}-{$skin_dir}-{$rows}-{$subject_len}.php";     return $file_name;} function cs_replace_latest_sql( $sql, $dbtable, $bo_table, $rows ){     global $wpdb;      //글 뽑아오기를 댓글수, 조회수, 좋아요, 게시글 순서 순으로 뽑아옵니다.     $sql = $wpdb->prepare("select * from {$dbtable} where bo_table = '%s' and wr_parent = 0 order by wr_comment desc, wr_hit desc, wr_good desc, wr_num limit 0, %d ", $bo_table, $rows);     return $sql;}

 

 

 

 

그런 다음 위젯에서 텍스트 위젯 으로 그 안에 숏코드를 아래와 같은 형식으로 넣습니다.

 

[gnucommerce_board_custom_latest bo_table="bo_table입력" rows=5] 


텍스트 위젯 안에 숏코드를 입력하는 방법은 아래 url을 참고해 주세요.

 

http://sir.co.kr/gnucommerce_tip/9 

 

 

 


로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

상세한 답변 감사드립니다. 그런데 코드를 수정하고 숏코드를 넣어보니 해당 자리에 "자료가 없습니다"라는 코멘트만 출력되네요..

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인
🐛 버그신고