2014-11-24 15 views
0

所以,這裏的交易,我有一個自定義的帖子類型和它的自定義分類,都啓用了層次結構。我註冊了自定義文章類型的 '類' 的分類裏,下面這個模板:爲什麼我的分類法不能在我的自定義帖子上運行分層方式?

  • 類別
    • 兒童類
    • 二孩類別

但是,當我在其中一個子類別中保存自定義帖子類型時,她不再是子類別,如下圖所示:

Result after saving

下面是一個被用於創建,分類和自定義後類型代碼:

$label = array(
    'name' => _x('Arquivos', 'post type general name'), 
    'singular_name' => _x('Arquivo', 'post type singular name'), 
    'add_new' => _x('Adicionar Arquivo', 'event'), 
    'add_new_item' => __('Adicionar novo Arquivo'), 
    'edit_item' => __('Editar Arquivo'), 
    'new_item' => __('Novo Arquivo'), 
    'view_item' => __('Ver Arquivo'), 
    'search_items' => __('Procurar Arquivo'), 
    'not_found' => __('Arquivo não encontrado'), 
    'not_found_in_trash' => __('Arquivo não encontrado na lixeira') 
); 

$args = array(
    'labels' => $label, 
    'public' => true, 
    'publicly_queryable' => true, 
    'show_ui' => true, 
    'query_var' => true, 
    'menu_icon' => 'dashicons-upload', 
    'rewrite' => true, 
    'capability_type' => 'post', 
    'hierarchical' => true, 
    'menu_position' => null, 
    'supports' => array('title', 'editor'), 
    'taxonomies' => Array('categorias_arquivos') 
); 

register_post_type('arquivos', $args); 

register_taxonomy('categorias_arquivos', array('arquivos'), array(
    'hierarchical' => true, 
    'label' => 'Categorias', 
    'singular_label' => 'Categoria', 
    'rewrite' => false) 
); 

register_taxonomy_for_object_type('categorias_arquivos', 'arquivos'); 

回答

0

WordPress的只顯示第一選擇的分類列表中,這並不使他們失去他們的等級以任何方式。在你的情況下,如果你將該帖子添加到「Jardim Cristal」類別中,樹會按照你的預期顯示。

此外,如果您轉到分類編輯屏幕,您會看到層次結構也存在。

雖然有點奇怪,但實際上,這只是一個視覺特徵,可以更容易區分帖子屬於哪些分類標準。

+0

以及如何列出每個父類別的子女,例如「Jardim Cristal」,我得到他的子女類別,並列出每個職位的職位? – 2014-11-24 20:15:58

相關問題