Ciao a tutti,

Ho creato un CTP chiamata "interventions". “Interventions” dovrebbe tenere 7 categorie. Ho messo sia l'archivio che tutte le categorie visualizzate sul menu del front-end. Nessun problema con l'archivio generale di "interventions", ma quando si tenta di utilizzare le sue categorie non funziona L'errore che risulta è che non trova la pagina della categoria quando si fa clic sulla voce del menu .

Questo è il codice che ho inserito in functions.php
/*—————————————————————————————*/
add_action( ‘init’, ‘register_my_cpts_interventions’ );
function register_my_cpts_interventions() {
$interv_labels = array(
“name” => __( ‘interventions’, ‘rookie’ ),
“singular_name” => __( ‘intervention’, ‘rookie’ ),
“menu_name” => __( ‘interventions active’, ‘rookie’ ),
“all_items” => __( ‘Tutte le interventions’, ‘rookie’ ),
‘edit_item’ => __( ‘Edit intervention’ ),
“archives” => __( ‘interventions’, ‘rookie’ ),
);
$args = array(
“label” => __( ‘interventions’, ‘rookie’ ),
“labels” => $interv_labels,
“description” => “”,
“public” => true,
“publicly_queryable” => true,
“show_ui” => true,
“show_in_rest” => false,
“rest_base” => “interventions”,
“has_archive” => true,
“show_in_menu” => true,
“exclude_from_search” => true,
“capability_type” => “post”,
“map_meta_cap” => true,
“hierarchical” => true,
“rewrite” => array( “slug” => “interventions”, “with_front” => true ),
“query_var” => “interventions”, //”intervention” è sbagliata !!!
“menu_icon” => “dashicons-megaphone”,
“supports” => array( “title”, “editor”, “interventions categories” ),
“taxonomies” => array( “interventions” ),
);
register_post_type( “interventions”, $args );
}
// End of register_my_cpts_interventions()
add_action( ‘init’, ‘register_my_taxonomies_interventions’ );
function register_my_taxonomies_interventions() {
$labels_taxo_interv = array(
“name” => __( ‘interventions categorie’, ‘rookie’ ),
“singular_name” => __( ‘category intervention’, ‘rookie’ ),
);
$args = array(
“label” => __( ‘interventions categories’, ‘rookie’ ),
“labels” => $labels_taxo_interv,
“public” => true,
“hierarchical” => true,
“label” => “interventions categories”,
“show_ui” => true,
“show_in_menu” => true,
“show_in_nav_menus” => true,
“query_var” => ‘interventions’,//true,
“rewrite” => array( ‘slug’ => ‘interventions categories’, ‘with_front’ => true, ‘hierarchical’ => true, ),
“show_admin_column” => false,
“show_in_rest” => false,
“rest_base” => “”,
“show_in_quick_edit” => false,
);
register_taxonomy( “interventions”, array( “interventions” ), $args );
// End register_my_taxes_interventions()
}
/*———————————————————————————-*/
I added also this function , as signaled on your FAQ section of the plugin
function add_custom_types_to_tax( $query ) {
if( is_category() || is_tag() && empty( $query->query_vars[‘suppress_filters’] ) ) {
// Get all your post types
$post_types = array( ‘post’, ‘interventions’ );
$query->set( ‘interventions’, $post_types );
return $query;
}
}
add_filter( ‘pre_get_posts’, ‘add_custom_types_to_tax’ );
/*———********************************************** *************************/
Ho provato anche a usare il plugin Custom Post Type UI ma il problema che risulta è lo stessi Non capisco cosa sbaglio. Qualcuno sa darmi una mano ?


Grazie in anticipo