Hello Marc,
this is the code for CPT:
function cptui_register_my_cpts_prodotto() {
/**
* Post Type: Prodotti.
*/
$labels = array(
"name" => __( "Prodotti", "custom-post-type-ui" ),
"singular_name" => __( "Prodotto", "custom-post-type-ui" ),
);
$args = array(
"label" => __( "Prodotti", "custom-post-type-ui" ),
"labels" => $labels,
"description" => "",
"public" => true,
"publicly_queryable" => true,
"show_ui" => true,
"delete_with_user" => false,
"show_in_rest" => false,
"rest_base" => "",
"rest_controller_class" => "WP_REST_Posts_Controller",
"has_archive" => false,
"show_in_menu" => true,
"show_in_nav_menus" => true,
"exclude_from_search" => false,
"capability_type" => "post",
"map_meta_cap" => true,
"hierarchical" => false,
"rewrite" => array( "slug" => "prodotto", "with_front" => true ),
"query_var" => true,
"supports" => array( "title", "editor", "thumbnail", "author" ),
"taxonomies" => array( "cat_prodotto" ),
);
register_post_type( "prodotto", $args );
}
add_action( 'init', 'cptui_register_my_cpts_prodotto' );
and this is the related taxonomy:
function cptui_register_my_taxes_cat_prodotto() {
/**
* Taxonomy: Categorie prodotto.
*/
$labels = array(
"name" => __( "Categorie prodotto", "custom-post-type-ui" ),
"singular_name" => __( "Categoria prodotto", "custom-post-type-ui" ),
);
$args = array(
"label" => __( "Categorie prodotto", "custom-post-type-ui" ),
"labels" => $labels,
"public" => true,
"publicly_queryable" => true,
"hierarchical" => true,
"show_ui" => true,
"show_in_menu" => true,
"show_in_nav_menus" => true,
"query_var" => true,
"rewrite" => array( 'slug' => 'cat_prodotto', 'with_front' => true, ),
"show_admin_column" => true,
"show_in_rest" => false,
"rest_base" => "cat_prodotto",
"rest_controller_class" => "WP_REST_Terms_Controller",
"show_in_quick_edit" => false,
);
register_taxonomy( "cat_prodotto", array( "prodotto" ), $args );
}
add_action( 'init', 'cptui_register_my_taxes_cat_prodotto' );
If you need more info just ask.