From 01a687e46872ba4bf178137aec065fcd0b03c2b7 Mon Sep 17 00:00:00 2001 From: Antoine Date: Mon, 12 May 2025 16:54:36 +0200 Subject: [PATCH] REFACTOR Update custom taxonomy registration to improve structure and labels --- includes/taxonomy.php | 66 ++++++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 26 deletions(-) diff --git a/includes/taxonomy.php b/includes/taxonomy.php index b8e937f..820099a 100644 --- a/includes/taxonomy.php +++ b/includes/taxonomy.php @@ -1,30 +1,44 @@ - true, - // This array of options controls the labels displayed in the WordPress Admin UI - 'labels' => array( - 'name' => _x( 'Thématiques', 'taxonomy general name' ), - 'singular_name' => _x( 'Thématique', 'taxonomy singular name' ), - 'search_items' => __( 'Chercher une Thématique' ), - 'all_items' => __( 'Toutes les Thématiques' ), - 'parent_item' => __( 'Thématique Parent' ), - 'parent_item_colon' => __( 'Thématique Parent:' ), - 'edit_item' => __( 'Editer la Thématique' ), - 'update_item' => __( 'Mettre à jour la Thématique' ), - 'add_new_item' => __( 'Ajouter une Thématique' ), - 'new_item_name' => __( 'Nom de la nouvelle Thématique' ), - 'menu_name' => __( 'Thématiques' ), - ), - // Control the slugs used for this taxonomy - 'rewrite' => array( - 'slug' => 'thematiques', // This controls the base slug that will display before each term - // 'with_front' => false, // Don't display the category base before "/locations/" - 'hierarchical' => true // This will allow URL's like "/locations/boston/cambridge/" - ), - )); +// Register Custom Taxonomy +function custom_taxonomy() +{ + + $labels = array( + 'name' => _x('Taxonomies', 'Taxonomy General Name', 'text_domain'), + 'singular_name' => _x('Taxonomy', 'Taxonomy Singular Name', 'text_domain'), + 'menu_name' => __('Taxonomy', 'text_domain'), + 'all_items' => __('All Items', 'text_domain'), + 'parent_item' => __('Parent Item', 'text_domain'), + 'parent_item_colon' => __('Parent Item:', 'text_domain'), + 'new_item_name' => __('New Item Name', 'text_domain'), + 'add_new_item' => __('Add New Item', 'text_domain'), + 'edit_item' => __('Edit Item', 'text_domain'), + 'update_item' => __('Update Item', 'text_domain'), + 'view_item' => __('View Item', 'text_domain'), + 'separate_items_with_commas' => __('Separate items with commas', 'text_domain'), + 'add_or_remove_items' => __('Add or remove items', 'text_domain'), + 'choose_from_most_used' => __('Choose from the most used', 'text_domain'), + 'popular_items' => __('Popular Items', 'text_domain'), + 'search_items' => __('Search Items', 'text_domain'), + 'not_found' => __('Not Found', 'text_domain'), + 'no_terms' => __('No items', 'text_domain'), + 'items_list' => __('Items list', 'text_domain'), + 'items_list_navigation' => __('Items list navigation', 'text_domain'), + ); + $args = array( + 'show_in_rest' => true, + 'labels' => $labels, + 'hierarchical' => false, + 'public' => true, + 'show_ui' => true, + 'show_admin_column' => true, + 'show_in_nav_menus' => true, + 'show_tagcloud' => true, + 'meta_box_cb' => true, + ); + register_taxonomy('taxonomy', array('articles', 'revues'), $args); } -add_action( 'init', 'add_custom_taxonomies', 0 ); \ No newline at end of file +// add_action('init', 'custom_taxonomy', 0);