답글의 카테고리에 원글의 카테고리가 자동으로 선택되도록 하는 방법

어떤 게시글에 답글을 달 때, 해당 답글의 카테고리가 자동으로 원글의 카테고리로 설정되도록 하고 싶습니다.

예를 들어 A, B, C 라는 카테고리가 있는 게시판에서 A 카테고리 글에 답글을 달면, 해당 답글의 카테고리가 자동으로 A 카테고리로 선택되도록 하는 것입니다.

이곳에서 찾아보니 아래와 같은 답글이 달린 것을 확인하였지만, 그대로 해도 전혀 변화가 없더라고요.

 

<option value="<?php echo $board->currentCategory()?>"<?php if($content->category1 == $board->currentCategory()):?> selected<?php endif?>><?php echo $board->currentCategory()?></option>

위 코드를 찾아서 아래 코드로 교체해주세요.

<option value="<?php echo $board->currentCategory()?>"<?php if(($content->category1?$content->category1:$parent->category1) == $board->currentCategory()):?> selected<?php endif?>><?php echo $board->currentCategory()?></option>


 

답글의 카테고리를 자동으로 원글의 카테고리에 맞추는 방법을 알려주시면 감사하겠습니다.

좋은 정보와 인맥을 동시에, 워드프레스 사용자 단톡방 참여하기
좋은 정보와 인맥을 동시에, 워드프레스 사용자 단톡방 참여하기
  • 안녕하세요~^^

    최신 버전의 KBoard(케이보드) 플러그인을 사용 중이시라면 새로운 방법을 안내해드리겠습니다.

    워드프레스 관리자 -> 외모 -> 테마 편집기 페이지에서 functions.php 파일 하단에

    아래의 코드를 추가해보시겠어요?

    add_filter('kboard_get_template_field_html', 'my_kboard_get_template_field_html', 10, 4);
    function my_kboard_get_template_field_html($field_html, $field, $content, $board){
    	$meta_key = (isset($field['meta_key'])&&$field['meta_key']) ? $field['meta_key'] : '';
    	$required = (isset($field['required'])&&$field['required']) ? 'required' : '';
    	$field_name = (isset($field['field_name'])&&$field['field_name']) ? $field['field_name'] : ((isset($field['field_label'])&&$field['field_label']) ? $field['field_label'] : '');
    	
    	if($board->id == '1'){
    		if($field['field_type'] == 'category1'){
    			if($content->parent_uid){
    				$parent = new KBContent();
    				$parent->initWithUID($content->parent_uid);
    			}
    			
    			ob_start();
    			?>
    			<?php if(!$board->isTreeCategoryActive()):?>
    				<?php if($board->initCategory1()):?>
    					<div class="kboard-attr-row <?php echo esc_attr($field['class'])?> <?php echo esc_attr($required)?>">
    						<label class="attr-name" for="<?php echo esc_attr($meta_key)?>"><span class="field-name"><?php echo esc_html($field_name)?></span><?php if($required):?> <span class="attr-required-text">*</span><?php endif?></label>
    						<div class="attr-value">
    							<select id="<?php echo esc_attr($meta_key)?>" name="category1" class="<?php echo esc_attr($required)?>">
    								<option value=""><?php echo __('Category', 'kboard')?> <?php echo __('Select', 'kboard')?></option>
    								<?php while($board->hasNextCategory()):?>
    								<option value="<?php echo $board->currentCategory()?>"<?php if(($content->category1?$content->category1:$parent->category1) == $board->currentCategory()):?> selected<?php endif?>><?php echo $board->currentCategory()?></option>
    								<?php endwhile?>
    							</select>
    							<?php if(isset($field['description']) && $field['description']):?><div class="description"><?php echo esc_html($field['description'])?></div><?php endif?>
    						</div>
    					</div>
    				<?php endif?>
    			<?php endif?>
    			<?php
    			$field_html = ob_get_clean();
    		}
    		
    		if($field['field_type'] == 'category2'){
    			if($content->parent_uid){
    				$parent = new KBContent();
    				$parent->initWithUID($content->parent_uid);
    			}
    			
    			ob_start();
    			?>
    			<?php if(!$board->isTreeCategoryActive()):?>
    				<?php if($board->initCategory2()):?>
    					<div class="kboard-attr-row <?php echo esc_attr($field['class'])?> <?php echo esc_attr($required)?>">
    						<label class="attr-name" for="<?php echo esc_attr($meta_key)?>"><span class="field-name"><?php echo esc_html($field_name)?></span><?php if($required):?> <span class="attr-required-text">*</span><?php endif?></label>
    						<div class="attr-value">
    							<select id="<?php echo esc_attr($meta_key)?>" name="category2" class="<?php echo esc_attr($required)?>">
    								<option value=""><?php echo __('Category', 'kboard')?> <?php echo __('Select', 'kboard')?></option>
    								<?php while($board->hasNextCategory()):?>
    								<option value="<?php echo $board->currentCategory()?>"<?php if(($content->category2?$content->category2:$parent->category2) == $board->currentCategory()):?> selected<?php endif?>><?php echo $board->currentCategory()?></option>
    								<?php endwhile?>
    							</select>
    							<?php if(isset($field['description']) && $field['description']):?><div class="description"><?php echo esc_html($field['description'])?></div><?php endif?>
    						</div>
    					</div>
    				<?php endif?>
    			<?php endif?>
    			<?php
    			$field_html = ob_get_clean();
    		}
    	}
    	return $field_html;
    }

    위의 코드에서 $board->id == '1' 부분은 실제 게시판 id로 적용해주세요.

     

    아래 링크도 참고해보시겠어요?

    https://blog.cosmosfarm.com/?p=214

    고맙습니다.

  • 정상적으로 작동되네요.

    알려주셔서 감사합니다.

  • 위의 코드가 최신버전의 Kboard에서도 유효한지요?

    적용해보았는데 답글에 원글의 카테고리가 적용되는 것은 정상 작동되는데 아래와 같은 오류코드가 발생하였습니다. 

    그리고 익스플로러에서 글을 등록하고나면 글이 등록된 후에 "권한이 없습니다"라는 오류 메세지가 뜹니다. 

    그래서 현재 위의 코드를 지우고 원상복구한 상태입니다. 

    아래코드의 line 231 부분이 알려주신 코드가 삽입된 부분입니다.
    -----------------------------------------------------

    •  Nov 18, 11:38:40

      Notice: Undefined variable: parent in /home/pkists54/public_html/wp-content/themes/enfold-child/functions.php on line 231

    •  Nov 18, 11:38:40

      Notice: Trying to get property of non-object in /home/pkists54/public_html/wp-content/themes/enfold-child/functions.php on line 231

    •  Nov 18, 11:38:40

      Notice: Undefined variable: parent in /home/pkists54/public_html/wp-content/themes/enfold-child/functions.php on line 231

    •  Nov 18, 11:38:40

      Notice: Trying to get property of non-object in /home/pkists54/public_html/wp-content/themes/enfold-child/functions.php on line 231

    •  Nov 18, 11:42:37

      Notice: Undefined variable: parent in /home/pkists54/public_html/wp-content/themes/enfold-child/functions.php on line 231

    •  Nov 18, 11:42:37

      Notice: Trying to get property of non-object in /home/pkists54/public_html/wp-content/themes/enfold-child/functions.php on line 231

    •  Nov 18, 11:42:37

      Notice: Undefined variable: parent in /home/pkists54/public_html/wp-content/themes/enfold-child/functions.php on line 231

    •  Nov 18, 11:42:37

      Notice: Trying to get property of non-object in /home/pkists54/public_html/wp-content/themes/enfold-child/functions.php on line 231

    •  Nov 18, 11:43:01

      Notice: Undefined variable: parent in /home/pkists54/public_html/wp-content/themes/enfold-child/functions.php on line 231

    •  Nov 18, 11:43:01

      Notice: Trying to get property of non-object in /home/pkists54/public_html/wp-content/themes/enfold-child/functions.php on line 231

    •  Nov 18, 11:43:01

      Notice: Undefined variable: parent in /home/pkists54/public_html/wp-content/themes/enfold-child/functions.php on line 231

    •  Nov 18, 11:43:01

      Notice: Trying to get property of non-object in /home/pkists54/public_html/wp-content/themes/enfold-child/functions.php on line 231

    •  Nov 18, 12:09:56

      Notice: Undefined variable: parent in /home/pkists54/public_html/wp-content/themes/enfold-child/functions.php on line 231

    •  Nov 18, 12:09:56

      Notice: Trying to get property of non-object in /home/pkists54/public_html/wp-content/themes/enfold-child/functions.php on line 231

    •  Nov 18, 12:09:56

      Notice: Undefined variable: parent in /home/pkists54/public_html/wp-content/themes/enfold-child/functions.php on line 231

    •  Nov 18, 12:09:56

      Notice: Trying to get property of non-object in /home/pkists54/public_html/wp-content/themes/enfold-child/functions.php on line 231

    •  Nov 18, 14:21:43

      Notice: Undefined variable: parent in /home/pkists54/public_html/wp-content/themes/enfold-child/functions.php on line 231

    •  Nov 18, 14:21:43

      Notice: Trying to get property of non-object in /home/pkists54/public_html/wp-content/themes/enfold-child/functions.php on line 231

    •  Nov 18, 14:21:43

      Notice: Undefined variable: parent in /home/pkists54/public_html/wp-content/themes/enfold-child/functions.php on line 231

    • Ignore

       Nov 18, 14:21:43

      Notice: Trying to get property of non-object in /home/pkists54/public_html/wp-content/themes/enfold-child/functions.php on line 231

     

  • 안녕하세요.

    최신 버전의 KBoard 플러그인에서 해당 코드는 정상적으로 동작합니다.

    게시판 권한 설정은 어떻게 되어 있으신지요?

    실제 추가하신 코드를 에디터의 코드 스니펫 삽입 기능으로 올려주시겠어요?

    고맙습니다.

  • 위에 알려주신 코드를 그대로 복사해서 넣고 board id 값만 변경해서 저장했는데 이번에도 계속 충돌이 납니다. 

    혹시 다른 코드랑 중복되거나 충돌이 되는지 싶어서 functions.php 전체 코드를 아래에 올리겠습니다.

    제일 밑에 부분이 이번에 추가한 코드입니다.

    <?php
    // Exit if accessed directly
    if ( !defined( 'ABSPATH' ) ) exit;
    
    // BEGIN ENQUEUE PARENT ACTION
    // AUTO GENERATED - Do not modify or remove comment markers above or below:
    
    // END ENQUEUE PARENT ACTION
    add_filter('kboard_content_date', 'my_kboard_content_date', 10, 3);
    function my_kboard_content_date($date, $content, $board){
    	$date = date('Y.m.d', strtotime($content->date));
    	return $date;
    }
    function my_login_logo() { ?>
    <style type="text/css">
    body.login div#login h1 a {
    background-image: url(<?php echo get_stylesheet_directory_uri(); ?>/images/site-login-logo.png);
    padding-bottom: 1px;
    }
    </style>
    <?php }
    add_action( 'login_enqueue_scripts', 'my_login_logo' );
    
    /*메인화면에게시글미리보기길이조정*/
    add_shortcode('my_kboard_latest_content_view', 'my_kboard_latest_content_view');
    function my_kboard_latest_content_view($args=array()){
    	global $wpdb;
    	$board_id = '7'; // 보여주고자 하는 게시판 번호 입력 
    	$result = $wpdb->get_row("SELECT * FROM `{$wpdb->prefix}kboard_board_content` WHERE `board_id`='$board_id' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval') ORDER BY `date` DESC LIMIT 1");
    	
    	if($result){
    		$content = new KBContent();
    		$content->initWithUID($result->uid);
    		$url = new KBUrl();
    		$router = new KBRouter();
    		$board_url = $router->getContentURL($result->uid);
    		
    		$content->content = wp_strip_all_tags($content->content);
    		$content->content = mb_strimwidth($content->content, 0, 250, '...', 'utf-8'); // 100 수치를 조절하시면 길이를 조절할 수 있습니다.
    		
    		ob_start();
            echo '<div class="kboard-title">';
            if($content->isNew()){
                echo '<span class="kboard-default-new-notify">N</span>';
            }
            echo '<a href="'.$url->set('uid', $content->uid)->set('mod', 'document')->toStringWithPath($board_url).'"> '.$content->title.'</a></div>';
            echo '<div class="kboard-content">'.$content->content.'</div>';
            return ob_get_clean();
    	}
    }
    
    /*댓글자동링크적용*/
    add_filter('kboard_comments_content', 'my_kboard_comments_content', 10, 3);
    function my_kboard_comments_content($comment, $comment_uid, $content_uid){
    	return preg_replace_callback('#(?i)(http|https)?(://)?(([-\w^@]+\.)+(kr|co.kr|go.kr|net|org|edu|gov|me|com|co+)(?:/[^,\s]*|))#', 'kboard_comment_autolink_prependHTTP', $comment);
    }
    
    function kboard_comment_autolink_prependHTTP($m){
    	$mStr = $m[1].$m[2].$m[3];
    	if(preg_match('#([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#', $mStr)){
    		return "<a href=\"mailto:".$m[2].$m[3]."\" target=\"_blank\">".$m[1].$m[2].$m[3]."</a>";
    	}
    	else{
    		$http = (!preg_match("#(https://)#", $mStr)) ? 'http://' : 'https://';
    		return "<a href=\"".$http.$m[3]."\" target=\"_blank\">".$m[1].$m[2].$m[3]."</a>";
    	}
    }
    /*최신글미리보기답글표시*/
    add_filter('kboard_list_where', 'my_kboard_list_where', 10, 3);
    function my_kboard_list_where($where, $board_id, $content_list){
    	if($content_list->is_latest && in_array($board_id, array('3', '4', '5', '6', '7', '9', '11', '15'))){
    		if($content_list->category1){
    			$where = "`board_id`='{$board_id}' AND `category1`='{$content_list->category1}' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
    		}
    		else{
    			$where = "`board_id`='{$board_id}' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
    		}
    	}
    	return $where;
    }
    /*특정글new표시길게*/
    add_filter('kboard_content_is_new', 'my_kboard_content_is_new', 10, 2);
    function my_kboard_content_is_new($is_new, $content){
    	if(in_array($content->uid, array(''))){ // 'uid번호'여러개일때는쉼표로구분함
    		$is_new = true;
    	}
    	return $is_new;
    }
    /*로그인사용자일때작성자입력필드표시시작*/
    add_action('init', 'kboard_comments_field_reshape');
    function kboard_comments_field_reshape(){
    	if(is_user_logged_in()){
    		
    		// 기존 댓글 입력 필드의 출력을 삭제합니다.
    		remove_action('kboard_comments_field', 'kboard_comments_field', 10, 4);
    		
    		// 새로운 댓글 입력 필드를 출력합니다.
    		add_action('kboard_comments_field', 'my_kboard_comments_field', 10, 4);
    	}
    }
    
    
    function my_kboard_comments_field($field_html, $board, $content_uid, $comment_builder){
    	?>
    	<div class="comments-field">
    		<label class="comments-field-label" for="comment_member_display"><?php echo __('Author', 'kboard-comments')?></label>
    		<input type="text" id="comment_member_display" name="member_display" value="" placeholder="<?php echo __('Author', 'kboard-comments')?>..." required>
    	</div>
    	<?php
    }
    
    /*새글과댓글알림기능추가*/
    add_action('kboard_comments_insert', 'my_kboard_comments_insert', 10, 3);
    function my_kboard_comments_insert($comment_uid, $content_uid, $board){
    	$comment = new KBComment();
    	$comment->initWithUID($comment_uid);
    	
    	if(!$board->isAdmin()){
    		if(!class_exists('KBMail')){
    			include_once KBOARD_DIR_PATH . '/class/KBMail.class.php';
    		}
    		$url = new KBUrl();
    		$mail = new KBMail();
    		$mail->to = explode(',', $board->meta->latest_alerts);
    		$mail->title = "댓글이 등록 되었습니다.";
    		$mail->content = $comment->content;
    		$mail->url = $url->getDocumentRedirect($content_uid);
    		$mail->url_name = '페이지로 이동';
    		$mail->send();
    	}
    }
    /*관리자에게만 아이피 표시*/
    add_filter('kboard_document_add_option_value_field_data', 'my_kboard_document_add_option_value_field_data', 10, 3);
    function my_kboard_document_add_option_value_field_data($field, $content, $board){
    	if(isset($field['meta_key']) && $field['meta_key'] == 'ip' && !$board->isAdmin()){
    		return array();
    	}
    	return $field;
    }
    /*구텐베르크 비활성화*/
    // Disable Gutenberg
    add_filter('use_block_editor_for_post', '__return_false');
    
    /*카테고리 필수 선택 문구 표시*/
    add_action('kboard_skin_field_after_category1', 'my_kboard_skin_field_after_category1', 10, 3);
    function my_kboard_skin_field_after_category1($field, $content, $board){
    	if(!$content->category1 && $board->id == '4'){ // 실제 게시판 id로 적용해주세요.
    		?>
    		<div class="kboard-attr-row kboard-attr-category1 ">
    			<div class="attr-value">
    				<div class="category1-required" style="color: red;">카테고리를 선택해주세요</div>
    			</div>
    		</div>
    		<?php
    	}
    }
    
    add_action('wp_head', 'my_head');
    function my_head(){
    	$page_id = get_the_ID();
    	if($page_id == '42'){ // 실제 페이지 ID로 적용해주세요.
    		?>
    		<script>
    		jQuery(document).ready(function(){
    			var form = jQuery('.kboard-form');
    			
    			kboard_category1_required(form);
    
    			jQuery('#category1', form).on('change', function(){
    				kboard_category1_required(form);
    			});
    		});
    		
    		function kboard_category1_required(form){
    			if(jQuery('#category1', form).val()){
    				jQuery('.category1-required').hide();
    			}
    			else{
    				jQuery('.category1-required').show();
    			}
    		}
    		</script>
    		<?php
    	}
    }
    /*통합검색 결과 키워드를 굵게 표시*/
    add_filter('the_excerpt', 'my_search_highlight');
    add_filter('the_title', 'my_search_highlight');
    function my_search_highlight($text){
    	if(is_search() && !is_admin()){
    		$keyword = isset($_GET['s']) ? sanitize_text_field($_GET['s']) : '';
    		if($keyword){
    			$text = str_replace($keyword , "<strong>{$keyword}</strong>", $text);
    		}
    	}
    	return $text;
    }
    /*게시글 목록 페이지에서 검색 시 키워드 굵게 표시*/
    add_filter('kboard_content_value', 'my_kboard_content_value', 10, 3);
    function my_kboard_content_value($value, $name, $content){
    	if(kboard_mod() == 'list' && kboard_keyword() && $name == 'title'){
    		$keyword = kboard_keyword();
    		$value = str_replace($keyword , "<strong>{$keyword}</strong>", $value);
    	}
    	return $value;
    }
    /*리스트 화면에서 카테고리를 보고 있을경우 글쓰기를 하면 리스트에서 선택된 카테고리가 자동으로 선택*/
    add_filter('kboard_get_template_field_html', 'my_kboard_get_template_field_html', 10, 4);
    function my_kboard_get_template_field_html($field_html, $field, $content, $board){
    	if($board->id == '2'){ // 실제 게시판 id로 적용해주세요.
    		if($field['field_type'] == 'category1'){
    			$fields = $board->fields();
    			$meta_key = (isset($field['meta_key']) && $field['meta_key']) ? $field['meta_key'] : '';
    			$field_name = (isset($field['field_name']) && $field['field_name']) ? $field['field_name'] : $field['field_label'];;
    			$required = (isset($field['required']) && $field['required']) ? $field['required'] : $field['required'];;
    			
    			ob_start();
    			?>
    			<?php if(!$board->isTreeCategoryActive()):?>
    				<?php if($board->initCategory1()):?>
    					<div class="kboard-attr-row <?php echo esc_attr($field['class'])?> <?php echo esc_attr($required)?>">
    						<label class="attr-name" for="<?php echo esc_attr($meta_key)?>"><span class="field-name"><?php echo esc_html($field_name)?></span><?php if($required):?> <span class="attr-required-text">*</span><?php endif?></label>
    						<div class="attr-value">
    							<select id="<?php echo esc_attr($meta_key)?>" name="category1" class="<?php echo esc_attr($required)?>">
    								<option value=""><?php echo __('Category', 'kboard')?> <?php echo __('Select', 'kboard')?></option>
    								<?php while($board->hasNextCategory()):?>
    								<option value="<?php echo $board->currentCategory()?>"<?php if(($content->category1?$content->category1:kboard_category1()) == $board->currentCategory()):?> selected<?php endif?>><?php echo $board->currentCategory()?></option>
    								<?php endwhile?>
    							</select>
    							<?php if(isset($field['description']) && $field['description']):?><div class="description"><?php echo esc_html($field['description'])?></div><?php endif?>
    						</div>
    					</div>
    				<?php endif?>
    			<?php endif?>
    			<?php
    			$field_html = ob_get_clean();
    		}
    		else if($field['field_type'] == 'category2'){
    			$fields = $board->fields();
    			$meta_key = (isset($field['meta_key']) && $field['meta_key']) ? $field['meta_key'] : '';
    			$field_name = (isset($field['field_name']) && $field['field_name']) ? $field['field_name'] : $field['field_label'];;
    			$required = (isset($field['required']) && $field['required']) ? $field['required'] : $field['required'];;
    			
    			ob_start();
    			?>
    			<?php if(!$board->isTreeCategoryActive()):?>
    				<?php if($board->initCategory2()):?>
    					<div class="kboard-attr-row <?php echo esc_attr($field['class'])?> <?php echo esc_attr($required)?>">
    						<label class="attr-name" for="<?php echo esc_attr($meta_key)?>"><span class="field-name"><?php echo esc_html($field_name)?></span><?php if($required):?> <span class="attr-required-text">*</span><?php endif?></label>
    						<div class="attr-value">
    							<select id="<?php echo esc_attr($meta_key)?>" name="category2" class="<?php echo esc_attr($required)?>">
    								<option value=""><?php echo __('Category', 'kboard')?> <?php echo __('Select', 'kboard')?></option>
    								<?php while($board->hasNextCategory()):?>
    								<option value="<?php echo $board->currentCategory()?>"<?php if(($content->category2?$content->category2:kboard_category2()) == $board->currentCategory()):?> selected<?php endif?>><?php echo $board->currentCategory()?></option>
    								<?php endwhile?>
    							</select>
    							<?php if(isset($field['description']) && $field['description']):?><div class="description"><?php echo esc_html($field['description'])?></div><?php endif?>
    						</div>
    					</div>
    				<?php endif?>
    			<?php endif?>
    			<?php
    			$field_html = ob_get_clean();
    		}
    	}
    	
    	return $field_html;
    }
    /*답글의 카테고리에 원글의 카테고리가 자동으로 선택되도록 하기*/
    add_filter('kboard_get_template_field_html', 'my_kboard_get_template_field_html', 10, 4);
    function my_kboard_get_template_field_html($field_html, $field, $content, $board){
    	$meta_key = (isset($field['meta_key'])&&$field['meta_key']) ? $field['meta_key'] : '';
    	$required = (isset($field['required'])&&$field['required']) ? 'required' : '';
    	$field_name = (isset($field['field_name'])&&$field['field_name']) ? $field['field_name'] : ((isset($field['field_label'])&&$field['field_label']) ? $field['field_label'] : '');
    	
    	if($board->id == '1'){
    		if($field['field_type'] == 'category1'){
    			if($content->parent_uid){
    				$parent = new KBContent();
    				$parent->initWithUID($content->parent_uid);
    			}
    			
    			ob_start();
    			?>
    			<?php if(!$board->isTreeCategoryActive()):?>
    				<?php if($board->initCategory1()):?>
    					<div class="kboard-attr-row <?php echo esc_attr($field['class'])?> <?php echo esc_attr($required)?>">
    						<label class="attr-name" for="<?php echo esc_attr($meta_key)?>"><span class="field-name"><?php echo esc_html($field_name)?></span><?php if($required):?> <span class="attr-required-text">*</span><?php endif?></label>
    						<div class="attr-value">
    							<select id="<?php echo esc_attr($meta_key)?>" name="category1" class="<?php echo esc_attr($required)?>">
    								<option value=""><?php echo __('Category', 'kboard')?> <?php echo __('Select', 'kboard')?></option>
    								<?php while($board->hasNextCategory()):?>
    								<option value="<?php echo $board->currentCategory()?>"<?php if(($content->category1?$content->category1:$parent->category1) == $board->currentCategory()):?> selected<?php endif?>><?php echo $board->currentCategory()?></option>
    								<?php endwhile?>
    							</select>
    							<?php if(isset($field['description']) && $field['description']):?><div class="description"><?php echo esc_html($field['description'])?></div><?php endif?>
    						</div>
    					</div>
    				<?php endif?>
    			<?php endif?>
    			<?php
    			$field_html = ob_get_clean();
    		}
    		
    		if($field['field_type'] == 'category2'){
    			if($content->parent_uid){
    				$parent = new KBContent();
    				$parent->initWithUID($content->parent_uid);
    			}
    			
    			ob_start();
    			?>
    			<?php if(!$board->isTreeCategoryActive()):?>
    				<?php if($board->initCategory2()):?>
    					<div class="kboard-attr-row <?php echo esc_attr($field['class'])?> <?php echo esc_attr($required)?>">
    						<label class="attr-name" for="<?php echo esc_attr($meta_key)?>"><span class="field-name"><?php echo esc_html($field_name)?></span><?php if($required):?> <span class="attr-required-text">*</span><?php endif?></label>
    						<div class="attr-value">
    							<select id="<?php echo esc_attr($meta_key)?>" name="category2" class="<?php echo esc_attr($required)?>">
    								<option value=""><?php echo __('Category', 'kboard')?> <?php echo __('Select', 'kboard')?></option>
    								<?php while($board->hasNextCategory()):?>
    								<option value="<?php echo $board->currentCategory()?>"<?php if(($content->category2?$content->category2:$parent->category2) == $board->currentCategory()):?> selected<?php endif?>><?php echo $board->currentCategory()?></option>
    								<?php endwhile?>
    							</select>
    							<?php if(isset($field['description']) && $field['description']):?><div class="description"><?php echo esc_html($field['description'])?></div><?php endif?>
    						</div>
    					</div>
    				<?php endif?>
    			<?php endif?>
    			<?php
    			$field_html = ob_get_clean();
    		}
    	}
    	return $field_html;
    }

     

  • 안녕하세요.

    올려주신 코드를 확인해보니 코드가 충돌 나는 건 PHP 함수명 중복 문제로 보입니다.

    워드프레스에서 액션과 필터는 여러 번 사용할 수 있지만

    PHP 함수명은 중복되어선 안 됩니다.

     

    기존에 추가되어 있던 my_kboard_get_template_field_html 부분은 그대로 두신 후

    새로 추가하신 코드 중 my_kboard_get_template_field_html 부분을

    my_kboard_get_template_field_html1 이런 식으로 교체해서 확인해보시겠어요?

    고맙습니다.

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