我创建了一个名为“ customer-stories”的自定义帖子类型,我可以显示单个页面,但不能显示类别模板的模板。
我想要一个用于所有类别的单独模板。现在,它以404.php作为类别。
这是在我的functions.php中:
function story_custom_post_type() {
$labels = array(
'name' => __( 'customer-stories' ),
'singular_name' => __( 'customer-stories'),
'menu_name' => __( 'customer-stories'),
'parent_item_colon' => __( 'Parent Story'),
'all_items' => __( 'All Story'),
'view_item' => __( 'View Story'),
'add_new_item' => __( 'Add New Story'),
'add_new' => __( 'Add New'),
'edit_item' => __( 'Edit Story'),
'update_item' => __( 'Update Story'),
'search_items' => __( 'Search Story'),
'not_found' => __( 'Not Found'),
'not_found_in_trash' => __( 'Not found in Trash')
);
$args = array(
'label' => __( 'customer-stories'),
'description' => __( 'customer-stories'),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'revisions', 'custom-fields'),
'public' => true,
'hierarchical' => false,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'has_archive' => true,
'can_export' => true,
'exclude_from_search' => false,
'yarpp_support' => true,
'taxonomies' => array('post_tag'),
'publicly_queryable' => true,
'rewrite' => array( 'slug' => 'customer-stories' ),
'capability_type' => 'page'
);
register_post_type( 'customer-stories', $args );
}
add_action( 'init', 'story_custom_post_type', 0 );
// Let us create Taxonomy for Custom Post Type
add_action( 'init', 'create_customer_stories_custom_taxonomy', 0 );
//create a custom taxonomy name it "type" for your posts
function create_customer_stories_custom_taxonomy() {
$labels = array(
'name' => _x( 'Category', 'taxonomy general name' ),
'singular_name' => _x( 'Category', 'taxonomy singular name' ),
'search_items' => __( 'Search Categories' ),
'all_items' => __( 'All Categories' ),
'parent_item' => __( 'Parent Category' ),
'parent_item_colon' => __( 'Parent Category:' ),
'edit_item' => __( 'Edit Category' ),
'update_item' => __( 'Update Category' ),
'add_new_item' => __( 'Add New Category' ),
'new_item_name' => __( 'New Category Name' ),
'menu_name' => __( 'Categories' ),
);
register_taxonomy('customer-stories-cat',array('customer-stories'), array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'customer-stories' ),
));
}
我尝试了taxonomy-customer-stories-cat.php,但是没有用。让我知道文件名和文件内的php代码是什么。
谢谢。
答案 0 :(得分:0)
您是否尝试过将永久链接重置为纯文本,如果没有尝试,请尝试然后刷新类别页面?