我有一个自定义的帖子类型,course
具有关联的自定义分类法curriculum-area
. 在permalink上domain.com/course/
, 所有课程的列表如预期所示。然而,在permalink上domain.com/curriculum-area/equality
, 它显示主页。(主页是一个静态页面)。相反,我希望它显示所有courses
在指定的curriculum-area
: equality
. 还有,如果我有front-page.php
, 此存档页还使用front-page.php
.
我怎样才能得到archive.php
要应用于此自定义分类的模板?
// functions.php:
<?php
// add thumbnail support
add_theme_support( \'post-thumbnails\' );
// add custom post type \'Course\'
add_action( \'init\', \'register_cpt_course\' );
function register_cpt_course() {
// custom taxonomy - curriculum area
$args_curriculum_area_taxonomy = array(
\'hierarchical\' => true,
\'labels\' => array(
\'name\' => \'Curriculum Areas\',
\'singular_name\' => \'Curriculum Area\'
),
\'show_ui\' => true,
\'show_admin_column\' => true,
\'update_count_callback\' => \'_update_post_term_count\',
\'query_var\' => true,
\'rewrite\' => true
);
register_taxonomy( \'Curriculum Area\', \'course\', $args_curriculum_area_taxonomy );
// custom post type - course
$cpt_course_args = array(
\'labels\' => array(
\'name\' => \'Courses\',
\'singular_name\' => \'course\'
),
\'hierarchical\' => false,
\'description\' => \'The place to display courses\',
\'supports\' => array( \'title\', \'editor\', \'thumbnail\', \'custom-fields\', \'revisions\' ),
\'taxonomies\' => array( \'curriculum_area\' ),
\'public\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'menu_position\' => 5,
\'show_in_nav_menus\' => true,
\'publicly_queryable\' => true,
\'exclude_from_search\' => false,
\'has_archive\' => true,
\'query_var\' => true,
\'can_export\' => true,
\'rewrite\' => array(
\'slug\' => \'course\',
\'with_front\' => true
),
\'capability_type\' => \'post\'
);
register_post_type( \'course\', $cpt_course_args );
}
?>