My problem is as follows, register a custom post type and a custom taxonomy for it, both with hierarchy enabled. Record the 'categories' of the custom type within the taxonomy, following the style
- Father
- Son
- Son Two
But when you save a custom type post into one of two child categories, the following happens:
That is, the custom type post is registered within the selected taxonomy, but it no longer follows the hierarchical level.
Below is the custom type post creation code and taxonomy.
$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');