我正在尝试创建自定义帖子类型。除了归档页面外,所有页面都工作正常。我的自定义帖子类型存档页面是存档课程。php,但它不工作,它显示默认存档。php。我的代码有错吗?
谁能帮帮我吗?
function td_courses() {
$labels = array(
\'name\' => _x( \'Courses\', \'td\' ),
\'singular_name\' => _x( \'Courses\', \'td\' ),
\'add_new\' => _x( \'Add New\', \'td\' ),
\'add_new_item\' => __( \'Add New course\' ),
\'edit_item\' => __( \'Edit course\' ),
\'new_item\' => __( \'New courses\' ),
\'all_items\' => __( \'Courses\' ),
\'view_item\' => __( \'View courses\' ),
\'search_items\' => __( \'Search courses\' ),
\'not_found\' => __( \'No courses found\' ),
\'not_found_in_trash\' => __( \'No courses found in the Trash\' ),
\'menu_name\' => \'Courses\'
);
$args = array(
\'labels\' => $labels,
\'public\' => true,
\'menu_position\' => 10,
\'menu_icon\' => \'dashicons-welcome-learn-more\',
\'supports\' => array( \'title\', \'editor\', \'thumbnail\', \'author\' ),
\'has_archive\' => true,
\'capability_type\' => \'page\',
\'rewrite\' => array( \'slug\' => \'course\' ),
);
register_post_type( \'courses\', $args );
}
add_action( \'init\', \'td_courses\' );
function td_courses_taxonomies() {
$labels = array(
\'name\' => _x( \'Course Categories\', \'td\' ),
\'singular_name\' => _x( \'Course Categories\', \'td\' ),
\'search_items\' => __( \'Search Course Categorie\' ),
\'all_items\' => __( \'All Course Categories\' ),
\'parent_item\' => __( \'Parent Course Categorie\' ),
\'parent_item_colon\' => __( \'Parent Course Categorie:\' ),
\'edit_item\' => __( \'Edit Course Categorie\' ),
\'update_item\' => __( \'Update Course Categorie\' ),
\'add_new_item\' => __( \'Add New Course Categorie\' ),
\'new_item_name\' => __( \'New Course Categorie Name\' ),
\'menu_name\' => __( \'Course Categorie\' ),
);
$args = array(
\'hierarchical\' => true,
\'labels\' => $labels,
\'show_ui\' => true,
\'show_admin_column\' => true,
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => \'courses-list\' ),
);
register_taxonomy( \'courses_category\', array( \'courses\' ), $args );
}
add_action( \'init\', \'td_courses_taxonomies\', 0 );
谢谢