Я создал собственную таксономию, которая работает нормально. Ниже приведен код:
add_action('init', 'canderel_game_taxonomy', 0);
function canderel_game_taxonomy() {
$labels = array(
'name' => 'Gamme',
'singular_name' => 'Gamme',
'search_items' => 'Recherche Gamme',
'all_items' => 'Toutes les Gammes',
'parent_item' => 'Gamme Parent',
'parent_item_colon' => 'Gamme Parent',
'edit_item' => 'Editer Gamme',
'update_item' => 'Enregistrer Gamme',
'add_new_item' => 'Nouvelle Gamme',
'menu_name' => 'Gammes'
);
register_taxonomy('gammes', array('produit'), array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'public' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'gamme' ),
));
}
Вот мой код для получения термина таксономии, но он каждый раз возвращает неверную таксономию.
$terms = get_terms([
'taxonomy' => 'gammes',
'hide_empty' => false,
]);