如何停止自定义帖子类型重定向到博客存档页面?或者我们可以为自定义帖子类型显示创建一个单独的页面吗?
为展览创建自定义帖子类型:
add_action('init','exhibits_custom_init');
function exhibits_custom_init(){
$labels = array(
'name' => _x('Exhibits', 'post type general name'),
'singular_name' => _x('Exhibit', 'post type singular name'),
'add_new' => _x('Add New', 'exhibit'),
'add_new_item' => __('Add New Exhibit'),
'edit_item' => __('Edit Exhibit'),
'new_item' => __('New Exhibit'),
'view_item' => __('View Exhibit'),
'search_items' => __('Search Exhibits'),
'not_found' => __('No Exhibits Found'),
'not_found_in_trash' => __('No Exhibits Found in Trash'),
'parent_item_colon' => '',
'menu_name' => 'Exhibits'
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array('slug' => 'exhibit'),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'supports' => array('title','thumbnail','editor'),
'taxonomies' => array('post_tag','post_category')
);
register_post_type('exhibit',$args);
}
function my_taxonomies_exhibit(){
$labels = array(
'name' => _x( 'Exhibit Categories', 'taxonomy general name' ),
'singular_name' => _x( 'Exhibit Category', 'taxonomy singular name' ),
'search_items' => __( 'Search Exhibit Categories' ),
'all_items' => __( 'All Exhibit Categories' ),
'parent_item' => __( 'Parent Exhibit Category' ),
'parent_item_colon' => __( 'Parent Exhibit Category:' ),
'edit_item' => __( 'Edit Exhibit Category' ),
'update_item' => __( 'Update Exhibit Category' ),
'add_new_item' => __( 'Add New Exhibit Category' ),
'new_item_name' => __( 'New Exhibit Category' ),
'menu_name' => __( 'Exhibit Categories' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
);
register_taxonomy( 'post_category', 'exhibit', $args );
}
add_action( 'init', 'my_taxonomies_exhibit', 0 );
此自定义帖子类型重定向到博客存档页面。我想在内容页面或单独的页面中显示它。