如何停止自定义帖子类型重定向到博客存档页面?

时间:2013-06-18 07:43:04

标签: wordpress custom-post-type

如何停止自定义帖子类型重定向到博客存档页面?或者我们可以为自定义帖子类型显示创建单独的页面吗?

为Exhibits创建自定义帖子类型:

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 );

此自定义帖子类型重定向到博客存档页面。我想在内容页面或单独的页面中显示它。

1 个答案:

答案 0 :(得分:0)

不知道如果我理解你的问题100%。如果您需要CPT的专用模板文件:Exhibits,重复的single.php重命名:single-exhibits.php和WP应该使用该模板文件作为Exhibits CPT。

您可能需要重新保存永久链接结构,先检查一下。

http://codex.wordpress.org/Template_Hierarchy#Custom_Post_Types_display