2013-11-22 50 views
0

我已经创建了一个自定义的帖子类型并添加了'taxonomies'=>数组('category')。但是当我添加一个类别时,它也可以在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); 
} 

回答

0

是的,你可以用其他的分类标准自定义后类型:喜欢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');