add_action( 'init', 'create_taxonomy' );
function create_taxonomy(){
register_taxonomy('genre', ['projects'], array(
'hierarchical' => false,
'labels' => array(
'name' => _x( 'Genres', 'taxonomy general name' ),
'singular_name' => _x( 'Genre', 'taxonomy singular name' ),
'search_items' => __( 'Search Genres' ),
'all_items' => __( 'All Genres' ),
'parent_item' => __( 'Parent Genre' ),
'parent_item_colon' => __( 'Parent Genre:' ),
'edit_item' => __( 'Edit Genre' ),
'update_item' => __( 'Update Genre' ),
'add_new_item' => __( 'Add New Genre' ),
'new_item_name' => __( 'New Genre Name' ),
'menu_name' => __( 'Genre' ),
),
'public' => true,
'show_ui' => true,
'query_var' => true,
));
$catalog_genres = get_terms( [
'taxonomy' => ['genre'],
'hide_empty' => false,
] );
foreach( $catalog_genres as $genre ){
var_dump($genre);
}
}