如何分离帖子和自定义帖子样式类别



我创建了一个自定义的post类型,并添加了"分类"=>数组("类别")。但当我添加一个类别时,它在Post类别中是可见的。有办法把他们分开吗?

add_action( 'init', 'create_News_postype' );
function create_News_postype() {
global $wp,$wp_rewrite;
$labels = array(
    'name' => _x('News', 'post type general name'),
    'singular_name' => _x('News', 'post type singular name'),
    'add_new' => _x('Add New', 'News'),
    'add_new_item' => __('Add New News'),
    'edit_item' => __('Edit News'),
    'new_item' => __('New News'),
    'view_item' => __('View News'),
    'search_items' => __('Search News'),
    'not_found' =>  __('No News found'),
    'not_found_in_trash' => __('No News found in Trash'),
    'parent_item_colon' => '',
);
$args = array(
    'label' => __('News'),
    'labels' => $labels,
    'public' => true,
    'can_export' => true,
    'show_ui' => true,
    '_builtin' => false,
    'capability_type' => 'post',
    'rewrite' => array( "slug" => 'News' ),
    'taxonomies'=>array('category'),
    'query_var' => true,
    'menu_icon' => '',  
    'menu_icon' => get_template_directory_uri().'/images/planner.png',  
    'hierarchical' => true,    
    'supports'=> array('title', 'thumbnail', 'editor', 'page-attributes') ,
    'show_in_nav_menus' => true,    
    'menu_position' => 6
);
register_post_type( 'new', $args);
}

是的,您可以对自定义帖子类型使用其他分类法:如news_category:下面是代码

function news_taxonomy() {  
 register_taxonomy(  
 'news_category',  
 'news',  
 array(  
    'hierarchical' => true,  
    'label' => 'Category',  
    'query_var' => true,  
    'rewrite' => array('slug' => 'news-category')  
 )  
);  
}  
 add_action( 'init', 'news_taxonomy' ); 

最新更新