0
X
Add Snippet To Project
New Project
Add To Existing Project
/**
* Registers the 'my_taxonomy' taxonomy.
*
* @return void
*/
function mohit_register_my_taxonomy() : void {
$labels = [
'name' => _x( 'My Taxonomies', 'Taxonomy Name', 'wpturbo-test' ),
'singular_name' => _x( 'My Taxonomy', 'Taxonomy Singular Name', 'wpturbo-test' ),
'menu_name' => __( 'Taxonomies ', 'wpturbo-test' ),
'all_items' => __( 'All Taxonomies ', 'wpturbo-test' ),
'parent_item' => __( 'Parent Item ', 'wpturbo-test' ),
'parent_item_colon' => __( 'Parent Item: ', 'wpturbo-test' ),
'new_item_name' => __( 'New Taxonomy ', 'wpturbo-test' ),
'add_new_item' => __( 'Add New ', 'wpturbo-test' ),
'edit_item' => __( 'Edit Taxonomy ', 'wpturbo-test' ),
'update_item' => __( 'Update ', 'wpturbo-test' ),
'view_item' => __( 'View Taxonomy ', 'wpturbo-test' ),
'add_or_remove_items' => __( 'Add Or Remove Items ', 'wpturbo-test' ),
'choose_from_most_used' => __( 'Choose From Most Used ', 'wpturbo-test' ),
'popular_items' => __( 'Popular Items ', 'wpturbo-test' ),
'search_items' => __( 'Search Items ', 'wpturbo-test' ),
'not_found' => __( 'Not Found ', 'wpturbo-test' ),
'no_terms' => __( 'No Items ', 'wpturbo-test' ),
'items_list' => __( 'Items List ', 'wpturbo-test' ),
'items_list_navigation' => __( 'Items List Navigation ', 'wpturbo-test' ),
];
$args = [
'labels' => $labels,
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_admin_column' => true,
'show_in_nav_menus' => true,
'show_tagcloud' => true,
'show_in_rest' => true,
'rest_base' => 'my_taxonomy',
'rest_controller_class' => 'WP_REST_my_taxonomy_Controller',
];
register_taxonomy( 'my_taxonomy', ['post'], $args );
}
add_action( 'init', 'mohit_register_my_taxonomy' );