0
다음 코드를 사용하여 테마 활성화시 페이지를 만듭니다. 페이지 템플리트가 테마의 루트에있을 때 모두 효과적입니다. 그러나 나는 'page-templates'디렉토리 (root -> page-templates) 내에서 내 템플릿 파일을 참조하려고합니다. 내가 도대체 뭘 잘못하고있는 겁니까?wordpress - 동적으로 하위 폴더에 템플릿이있는 페이지 생성
if (isset($_GET['activated']) && is_admin()){
add_action('init', 'create_initial_pages');
}
function create_initial_pages() {
$pages = array(
// Page Title and URL (a blank space will end up becomeing a dash "-")
'Services' => array(
// Page Content // Template to use (if left blank the default template will be used)
'Services Content'=>'page-bottom-sidebar.php'),
);
foreach($pages as $page_url_title => $page_meta) {
$id = get_page_by_title($page_url_title);
foreach ($page_meta as $page_content=>$page_template){
$page = array(
'post_type' => 'page',
'post_title' => $page_url_title,
'post_name' => $page_url_title,
'post_status' => 'publish',
'post_content' => $page_content,
'post_parent' => ''
);
if(!isset($id->ID)){
$new_page_id = wp_insert_post($page);
if(!empty($page_template)){
update_post_meta($new_page_id, '_wp_page_template', $page_template);
}
}
}
};
}
도움을 주시면 대단히 감사하겠습니다. 나는 그저 볼 수없는 단순한 것을 알고 있습니다.