위의 링크대로 functions.php에 아래 코드를 입력하여, 1개의 게시판(default skin)에 적용을 완료하였습니다.
1개 게시판을 더 생성하여 사용하고자 하는데, 게시판 ID값을 추가하는 것이 애매합니다.
이에 대한 답변을 주시면 감사하겠습니다.
/*주소 우편번호 필드*/
add_filter('kboard_skin_fields', 'my_kboard_skin_fields', 10, 2);
function my_kboard_skin_fields($fields, $board){
if($board->id == '5'){ // 실제 적용될 게시판 ID 값으로 변경해주세요.
if(!isset($fields['address'])){
$fields['address'] = array(
'field_type' => 'address',
'field_label' => '주소',
'class' => 'kboard-attr-text',
'hidden' => '',
'meta_key' => '',
'field_name' => '',
'permission' => '',
'roles' => '',
'default_value' => '',
'placeholder' => '',
'required' => '',
'show_document' => '',
'description' => '',
'close_button' => 'yes'
);
}
}
return $fields;
}
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($field['field_type'] == 'address'){
// 페이지에 Daum 우편번호 서비스 자바스크립트 라이브러리를 추가합니다.
wp_enqueue_script('daum-postcode', 'https://spi.maps.daum.net/imap/map_js_init/postcode.v2.js', array(), '', true);
ob_start();
?>
<div class="kboard-attr-row">
<label class="attr-name" for="kboard_option_postcode">우편번호/주소</label>
<div class="attr-value">
<input type="text" id="kboard_option_postcode" name="kboard_option_postcode" value="<?php echo $content->option->postcode?>" placeholder="우편번호..." style="width:100px">
<input type="text" id="kboard_option_address" name="kboard_option_address" value="<?php echo $content->option->address?>" placeholder="주소...">
<button type="button" class="kboard-default-button-small" onclick="kboard_postcode_address_search()">우편번호/주소 검색</button>
</div>
</div>
<script>
function kboard_postcode_address_search(){
var width = 500;
var height = 600;
new daum.Postcode({
width: width,
height: height,
oncomplete: function(data){
jQuery('#kboard_option_postcode').val(data.zonecode);
jQuery('#kboard_option_address').val(data.roadAddress);
setTimeout(function(){
jQuery('#kboard_option_address').focus();
});
}
}).open({
left: (screen.availWidth-width)*0.5,
top: (screen.availHeight-height)*0.5
});
}
</script>
<?php
$field_html = ob_get_clean();
}
return $field_html;
}
add_filter('kboard_document_add_option_value_field_html', 'my_kboard_document_add_option_value_field_html', 10, 4);
function my_kboard_document_add_option_value_field_html($value_html, $field, $content, $board){
if($field['field_type'] == 'address'){
$value_html = sprintf('<div class="kboard-document-add-option-value meta-key-%s"><span class="option-name">%s</span> : %s</div><hr>', $field['field_type'], $field['field_name'], "({$content->option->postcode}) {$content->option->address}");
}
return $value_html;
}