카테고리별 베스트게시물 기준 및 추천시 획득 포인트 변화

예를 들어서 1게시판에서 debate을 선택하면 추천 10이 기준이고, news를 선택하면 추천 20이 기준이되고, meme을 선택하면 추천 30이 기준이 되게 하려 합니다.

일단 이것 저것 보면서 코드를 짜보려고 했지만 모르겠는게 있어서 올립니다. 일단 functions.php를 이렇게 바꿀 예정입니다.

추가적으로 작성자들이 카테고리를 설정하면 자동으로 카테고리를 인식해서 기준에따라 베스트를 나누어야할텐데 editor나 document를 바꿔야하는건가요? 카테고리를 코드를 뭐라고 넣어야하나요? 넣어야하는듯 한데 어떻게 하나요?

<?php

function theme_enqueue_styles() {
    wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array( 'avada-stylesheet' ) );
}
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );

function avada_lang_setup() {
	$lang = get_stylesheet_directory() . '/languages';
	load_child_theme_textdomain( 'Avada', $lang );
}
add_action( 'after_setup_theme', 'avada_lang_setup' );

add_filter('kboard_list_where', 'my_kboard_list_where', 10, 3);
function my_kboard_list_where($where, $board_id, $content_list){
	if($board_id == '8'){
		$vote1 = '10';
    $vote2 = '20';//기존에서 이렇게 추가하였습니다.
    $vote1 = '30';
		$where = "`vote`>='{$vote1}' AND `board_id` IN ('3') AND `category`='debate' AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
    $where = "`vote`>='{$vote2}' AND `board_id` IN ('3') AND `category`='news' AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
    $where = "`vote`>='{$vote3}' AND `board_id` IN ('3') AND `category`='meme' AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
	}
  if($board_id == '9'){
    $vote = '10';
    $where = "`vote`>='{$vote1}' AND `board_id` IN ('2') AND `category`='debate' AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
    $where = "`vote`>='{$vote2}' AND `board_id` IN ('2') AND `category`='news' AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
    $where = "`vote`>='{$vote3}' AND `board_id` IN ('2') AND `category`='meme' AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
	}
  if($board_id == '10'){
    $vote = '10';
    $where = "`vote`>='{$vote1}' AND `board_id` IN ('6') AND `category`='debate' AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
    $where = "`vote`>='{$vote2}' AND `board_id` IN ('6') AND `category`='news' AND `parent_uid`='0' AND `notice`='' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
    $where = "`vote`>='{$vote3}' AND `board_id` IN ('6') AND `category`='meme' 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('8','9','10'))){
		$orderby = "(`vote`) DESC, `date` DESC";
	}
	return $orderby;
}

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 == '8'){
		$allowed_board_id = array('8', '3');
	}
  elseif ($allowed_board_id == '9') {
    $allowed_board_id = array('9', '2');
	}
  elseif ($allowed_board_id == '10') {
    $allowed_board_id = array('10', '6');
  }
	return $allowed_board_id;
}

두번째로 카테고리에 따라 추천받을시 획득하는 포인트를 다르게 하고자합니다.

 

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

을 참고하여 해결하고자 하나 추가적 조건으로 카테고리에 따라 포인트 증가를 바꿀경우

add_action('kboard_content_like', 'my_kboard_content_like', 10, 2);
function my_kboard_content_like($content, $board){
	if($content->member_uid){
		mycred_add('kboard_content_like', $content->member_uid, 1, 'KBoard 좋아요 포인트', $content->uid);
	}
}

에서 카테고리에 대한 조건을 어디에 넣어야하나요...?

 

언제나 친절하게 답변해주셔서 감사합니다. ㅠㅠ

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