只有一个CPT的类别

时间:2015-07-09 11:04:35

标签: wordpress categories custom-post-type taxonomy

我创建了CPT并添加了分类法类别。 问题是来自CPT的那些类别也出现在我的博客中。 我希望在我的博客中有不同的类别,并且在我的CPT组合中有所不同。

这是我目前的代码     add_action(' init',' create_post_type');     function create_post_type(){

    register_post_type( 'portfolio',
        array(
            'labels' => array(
                'label' => 'portfolio',
                'name' => __( 'Portfolio' ),
                'singular_name' => __( 'portfolio' )
            ),
        'public' => true,
        'has_archive' => true,
        'taxonomies' => array('category','post_tag'),
        'supports' => array( 'title', 'comments', 'excerpt', 'custom-fields', 'thumbnail' )
        )
    );
};

1 个答案:

答案 0 :(得分:0)

引用codex

  

“即使您在创建帖子类型时注册了分类,也可以   必须仍然使用明确注册和定义分类法   register_taxonomy()

基本上,您正在为您的投资组合CPT创建一个名为类别的新分类法。这将不包括帖子的默认类别分类。

相关问题