2014-01-27 121 views
0

我想創建一個具有分類標準的自定義帖子類型。當我激活我的插件時,我在儀表板上看到所有類別的帖子。但是我只顯示分類標準類別而不是類別。創建一個具有分類標準的自定義帖子類型

function propertyinfo_setup_post_types() { 

    $PROPERTY_labels = apply_filters('propertyinfo_labels', array(
     'name'    => 'Property Info', 
     'singular_name'  => 'Property Info', 
     'add_new'    => __('Add New', 'propertyinfo'), 
     'add_new_item'  => __('Add New Property', 'propertyinfo'), 
     'edit_item'   => __('Edit Property Info', 'propertyinfo'), 
     'edit_item'   => __('Edit Property Info', 'propertyinfo'), 
     'new_item'   => __('New Property Info', 'propertyinfo'), 
     'all_items'   => __('All Property', 'propertyinfo'), 
     'view_item'   => __('View Property', 'propertyinfo'), 
     'search_items'  => __('Search Propertys', 'propertyinfo'), 
     'not_found'   => __('No Propertys found', 'propertyinfo'), 
     'not_found_in_trash' => __('No Propertys found in Trash', 'propertyinfo'), 
     'parent_item_colon' => '', 
     'menu_name'   => __('Property Info', 'propertyinfo'), 
     'exclude_from_search' => true 
    )); 


    $PROPERTY_args = array(
     'labels'   => $PROPERTY_labels, 
     'public'   => true, 
     'taxonomies' => array('category',), 
     'publicly_queryable'=> true, 
     'show_ui'   => true, 
     'show_in_menu'  => true, 
     'query_var'   => true, 
     'capability_type' => 'post', 
     'has_archive'  => true, 
     'hierarchical'  => true, 
     'supports'   => apply_filters('propertyinfo_supports', array('title', 'editor','thumbnail','author')), 
    ); 
    register_post_type('propertyinfo', apply_filters('propertyinfo_post_type_args', $PROPERTY_args)); 

} 

add_action('init', 'propertyinfo_setup_post_types'); 
+0

您還沒有真正問過問題。你的意思是說,當你在管理區簽出你的自定義發佈類型時,「類別」沒有列在它的下面?如果是這種情況,請嘗試直接在'taxonomies'數組中的'category'後面刪除逗號。 –

回答

1

註冊分類是不同的。

添加此代碼並從屬性args中刪除taxonomies' => array('category')

register_taxonomy("main_title", array("Property Info"), array("hierarchical" => true, "label" => "cat_lable", "singular_label" => "singular_label", "rewrite" => true)); 
相關問題