Create hierarchical custom taxonomy
if ( ! function_exists( 'ws_markets_hierarchical_taxonomy' ) ) {
// Register Custom Taxonomy
function ws_markets_hierarchical_taxonomy() {
$labels = array(
'name' => _x( 'Markets', 'Taxonomy General Name', 'astra' ),
'singular_name' => _x( 'Market', 'Taxonomy Singular Name', 'astra' ),
'menu_name' => __( 'Markets', 'astra' ),
'all_items' => __( 'All Markets', 'astra' ),
'parent_item' => __( 'Parent Market', 'astra' ),
'parent_item_colon' => __( 'Parent Market:', 'astra' ),
'new_item_name' => __( 'New Market Name', 'astra' ),
'add_new_item' => __( 'Add New Market', 'astra' ),
'edit_item' => __( 'Edit Market', 'astra' ),
'update_item' => __( 'Update Market', 'astra' ),
'view_item' => __( 'View Market', 'astra' ),
'separate_items_with_commas' => __( 'Separate markets with commas', 'astra' ),
'add_or_remove_items' => __( 'Add or remove markets', 'astra' ),
'choose_from_most_used' => __( 'Choose from the most used', 'astra' ),
'popular_items' => __( 'Popular Items', 'astra' ),
'search_items' => __( 'Search Markets', 'astra' ),
'not_found' => __( 'Not Found', 'astra' ),
'no_terms' => __( 'No markets', 'astra' ),
'items_list' => __( 'Markets list', 'astra' ),
'items_list_navigation' => __( 'Markets list navigation', 'astra' ),
);
$rewrite = array(
'slug' => 'market',
'with_front' => true,
'hierarchical' => false,
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_admin_column' => true,
'show_in_nav_menus' => true,
'show_tagcloud' => true,
'rewrite' => $rewrite,
'show_in_rest' => true,
);
register_taxonomy( 'markets', array( 'merchandise' ), $args );
}
add_action( 'init', 'ws_markets_hierarchical_taxonomy', 0 );
}