1
My problem is the following, record a custom post type and a custom taxonomy for the same, both with hierarchy enabled. Record custom type 'categories' within taxonomy, following the style
- Father
- Son
- Son Two
But when saving a custom type post within one of the two child categories, the following happens:
That is, the custom type post is registered within the selected taxonomy, but it ceases to follow the hierarchical level.
Below is the creation code for custom type post 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');