I have created a custom taxonomy that I have associated to my CPT. both appear on my dashboard, the issue is that when I add content and I want to choose a term from the list of the custom taxonomy, there is no value (no list, no checkbox…) . I am using wordpress 5.1. Here is the code added to functions.php :
function type_custom_taxonomy() {
$labels = array(
'name' => _x( 'Types', 'taxonomy general name' ),
'singular_name' => _x( 'Type', 'taxonomy singular name' ),
'menu_name' => __( 'Types' ),
);
register_taxonomy('types',array('action'), array(
'labels' => $labels,
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_admin_column' => true,
'show_in_rest' => true,
'show_tagcloud' => false,
));
}
add_action( 'init', 'type_custom_taxonomy', 0 );
//CPT
function action_post_type() {
register_post_type( 'action',
array(
'labels' => array(
'name' => __( 'Actions' ),
'singular_name' => __( 'Action' )
),
'public' => true,
'has_archive' => true,
'show_in_rest' => true,
'supports' => array('title', 'editor','thumbnail'),
'taxonomies' => array('types')
)
);
}
add_action( 'init', 'action_post_type' );
Changing the slug of taxonomy works for me. Don’t know the reason behind it but it works.