글쓰기 후 이동페이지 카테고리별로 다르게 설정하는 방법

1. 정확한 제품 또는 플러그인 이름

케이보드 컨텍트폼 게시판

 

2. 상세 내용

게시글 작성(글쓰기) 후 이동할 페이지는 아래 코드로 설정할 수 있는 걸로 압니다. 

한 게시판에서 작성한 글의 카테고리마다 다른 페이지로 이동하게 설정할 수도 있나요?

add_filter('kboard_after_executing_url', 'my_kboard_after_executing_url', 10, 3);
function my_kboard_after_executing_url($next_page_url, $content_uid, $board_id){
	if($board_id == '1'){
		$next_page_url = '페이지주소1';
	}
	
	if($board_id == '2'){
		$next_page_url = '페이지주소2';
	}
	
	if($board_id == '3'){
		$next_page_url = '페이지주소3';
	}
	return $next_page_url;
}

 

3. 확인 가능한 상세 페이지 주소

 

 

4. 수정한 코드 내역 (있다면)

 

 

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

    아래 예제 코드를 참고하여 적용해보시겠어요?

    add_filter('kboard_after_executing_url', 'my_kboard_after_executing_url', 10, 3);
    function my_kboard_after_executing_url($next_page_url, $content_uid, $board_id){
    	$kb_content = new KBContent();
    	$content    = $kb_content->initWithUID($content_uid);
    	if($board_id == '1'){
    		if($content->category1 == 'AAA'){
    			$next_page_url = '페이지주소1';
    		}
    	}
    	else if($board_id == '2'){
    		if($content->category1 == 'BBB'){
    			$next_page_url = '페이지주소1';
    		}
    	}
    	else if($board_id == '3'){
    		if($content->category1 == 'CCC'){
    			$next_page_url = '페이지주소1';
    		}
    	}
    	return $next_page_url;
    }

    고맙습니다.

  • 계층형 카테고리의 경우 아래와 같이 설정하는게 맞을까요?

    이렇게 설정하니까 모든 카테고리가 가장 첫 if문에 설정한 페이지주소1로 이동하네요 ㅜㅜ

    add_filter('kboard_after_executing_url', 'my_kboard_after_executing_url', 10, 3);
    function my_kboard_after_executing_url($next_page_url, $content_uid, $board_id){
    	$kb_content = new KBContent();
    	$content    = $kb_content->initWithUID($content_uid);
    	if($board_id == '16'){
    		if($content->tree-category == 'AAA'){
    			$next_page_url = '페이지주소1';
    		}
    	}
    	else if($board_id == '16'){
    		if($content->tree-category == 'BBB'){
    			$next_page_url = '페이지주소2';
    		}
    	}
    	return $next_page_url;
    }

     

    혹시나 싶어

    아래와 같이 if문을 고쳐보았는데도 모두 페이지주소1로 이동합니다.ㅠㅠ

    add_filter('kboard_after_executing_url', 'my_kboard_after_executing_url', 10, 3);
    function my_kboard_after_executing_url($next_page_url, $content_uid, $board_id){
    	$kb_content = new KBContent();
    	$content    = $kb_content->initWithUID($content_uid);
    	if($board_id == '16'){
    		if($content->tree-category == 'AAA'){
    			$next_page_url = '페이지주소1';
    		}
    		else if($content->tree-category == 'BBB'){
    			$next_page_url = '페이지주소2';
    		}
    	}
    	return $next_page_url;
    }

     

  • 계층형 카테고리의 경우 옵션에 적용되어 있습니다.

    $content->option->tree_category_1

    카테고리 부분을 위와 같이 변경하여 적용해보시겠어요?

    고맙습니다.

  • 감사합니다. 아래 코드로 잘 적용했습니다!

    add_filter('kboard_after_executing_url', 'my_kboard_after_executing_url', 10, 3);
    function my_kboard_after_executing_url($next_page_url, $content_uid, $board_id){
    	$kb_content = new KBContent();
    	$content    = $kb_content->initWithUID($content_uid);
    	if($board_id == '1'){
    		if($content->option->tree_category_1 == 'AAA'){
    			$next_page_url = '이동링크1';
    		}
    		else if($content->option->tree_category_1 == 'BBB'){
    			$next_page_url = '이동링크2';
    		}
    	}
    	return $next_page_url;
    }

     

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