true, 'labels' => array( 'name' => __('Thématiques', 'homegrade-theme__texte-backoffice'), 'singular_name' => __('Thématique', 'homegrade-theme__texte-backoffice'), 'search_items' => __('Chercher une Thématique', 'homegrade-theme__texte-backoffice'), 'all_items' => __('Toutes les Thématiques', 'homegrade-theme__texte-backoffice'), 'parent_item' => __('Thématique Parent', 'homegrade-theme__texte-backoffice'), 'parent_item_colon' => __('Thématique Parent:', 'homegrade-theme__texte-backoffice'), 'edit_item' => __('Editer la Thématique', 'homegrade-theme__texte-backoffice'), 'update_item' => __('Mettre à jour la Thématique', 'homegrade-theme__texte-backoffice'), 'add_new_item' => __('Ajouter une Thématique', 'homegrade-theme__texte-backoffice'), 'new_item_name' => __('Nom de la nouvelle Thématique', 'homegrade-theme__texte-backoffice'), 'menu_name' => __('Thématiques', 'homegrade-theme__texte-backoffice'), ), 'public' => true, 'show_in_rest' => true, // Needed for tax to appear in Gutenberg editor 'show_ui' => true, 'show_admin_column' => false, 'hierarchical' => true, // This will allow URL's like "/locations/boston/cambridge/" 'show_in_quick_edit' => false, 'meta_box_cb' => false, 'rewrite' => array( 'slug' => 'questions-thematiques', // 'with_front' => false, 'hierarchical' => true, 'has_archive' => true ), )); // ————— Type de news ————— register_taxonomy('news-type', 'post', array( 'labels' => array( 'name' => __('Types', 'homegrade-theme__texte-backoffice'), 'singular_name' => __('Type', 'homegrade-theme__texte-backoffice'), 'search_items' => __('Chercher un Type', 'homegrade-theme__texte-backoffice'), 'all_items' => __('Tous les Types', 'homegrade-theme__texte-backoffice'), 'parent_item' => __('Type Parent', 'homegrade-theme__texte-backoffice'), 'parent_item_colon' => __('Type Parent:', 'homegrade-theme__texte-backoffice'), 'edit_item' => __('Editer le Type', 'homegrade-theme__texte-backoffice'), 'update_item' => __('Mettre à jour le Type', 'homegrade-theme__texte-backoffice'), 'add_new_item' => __('Ajouter un Type', 'homegrade-theme__texte-backoffice'), 'new_item_name' => __('Nom du nouveau Type', 'homegrade-theme__texte-backoffice'), 'menu_name' => __('Type', 'homegrade-theme__texte-backoffice'), ), 'hierarchical' => false, )); // ————— mots-clés ————— register_taxonomy('mots-cles', ['questions', 'conseils'], array( // This array of options controls the labels displayed in the WordPress Admin UI 'labels' => array( 'name' => __('Mots-Clés', 'homegrade-theme__texte-backoffice'), 'singular_name' => __('Mots-Clés', 'homegrade-theme__texte-backoffice'), 'search_items' => __('Chercher un Mots-Clé', 'homegrade-theme__texte-backoffice'), 'all_items' => __('Tous les Mots-Clés', 'homegrade-theme__texte-backoffice'), 'parent_item' => __('Mots-Clé Parent', 'homegrade-theme__texte-backoffice'), 'parent_item_colon' => __('Mots-Clé Parent:', 'homegrade-theme__texte-backoffice'), 'edit_item' => __('Editer le Mots-Clé', 'homegrade-theme__texte-backoffice'), 'update_item' => __('Mettre à jour le Mots-Clé', 'homegrade-theme__texte-backoffice'), 'add_new_item' => __('Ajouter un Mots-Clé', 'homegrade-theme__texte-backoffice'), 'new_item_name' => __('Nom du nouveau Mots-Clés', 'homegrade-theme__texte-backoffice'), 'menu_name' => __('Mots-Clés', 'homegrade-theme__texte-backoffice'), ), 'hierarchical' => false, 'public' => false, )); } add_action('init', 'homegrade_add_custom_taxonomies', 0); /* ----------------------- HIDE THEMATIQUE METABOX -------------------------*/ // on passe le metabox_cb à false pour ne pas afficher la metabox function tna_edit_taxonomy_args($args, $tax_slug, $cptui_tax_args) { // Alternatively, you can check for specific taxonomies. if ('thematiques' === $tax_slug) { $args['meta_box_cb'] = false; } return $args; } add_filter('cptui_pre_register_taxonomy', 'tna_edit_taxonomy_args', 10, 3); // on récupère les élément avec un metabox_cb false et on les masque dans la sidebar add_filter('rest_prepare_taxonomy', function ($response, $taxonomy, $request) { $context = !empty($request['context']) ? $request['context'] : 'view'; // Context is edit in the editor if ($context === 'edit' && $taxonomy->meta_box_cb === false) { $data_response = $response->get_data(); $data_response['visibility']['show_ui'] = false; $response->set_data($data_response); } return $response; }, 10, 3);