용어가 섞여있을 수 있으므로 따라 주시기 바랍니다.wordpress를 추가 할 때
나는의 사용자 지정 게시 유형이 '패키지' 나는라는 가지 범주를 만들 수있는 기능을 설정 한 '추가 패키지 유형'
내가 카테고리를 추가 할 때 나는의 제목으로 새 페이지를 삽입 할 새로운 카테고리는 '패키지 유형 추가'에있는 경우에만 표시됩니다.
다음 코드로 범주 제목을 얻지 못하는 것 같습니다. $ 분류 안에 '패키지 유형 추가'가 표시됩니다. 그러나 방금 입력 한 제목과 같은 이름으로 페이지를 갖고 싶습니다.
감사
function custom_create_packages($term_id, $tt_id, $taxonomy){
if($taxonomy == 'package type'){
$new_page_title = $cat_title;
$new_page_content = 'This is the page content';
$new_page_template = ''; //ex. template-custom.php. Leave blank if you don't want a custom page template.
//don't change the code bellow, unless you know what you're doing
$page_check = get_page_by_title($new_page_title);
$new_page = array(
'post_type' => 'page',
'post_title' => $new_page_title,
'post_content' => $new_page_content,
'post_status' => 'publish',
'post_author' => 1,
);
if(!isset($page_check->ID)){
$new_page_id = wp_insert_post($new_page);
if(!empty($new_page_template)){
update_post_meta($new_page_id, '_wp_page_template', $new_page_template);
}
}
}
}
add_action('create_term', 'custom_create_packages', 10, 3);