Question

i have created custom taxonomy named Locations , everything is working fine, but whenever i add a taxonomy, everywhere is showing the taxonomy name as Category not as Location, Like Add New category and so on , in wp-admin

function reg_location_taxonomy() {
    register_taxonomy( 'location', array( 'product' ), array( 'hierarchical' => true, 'label' => 'Locations', 'singular_label' => 'Location', 'rewrite' => true ) );
    // register_taxonomy_for_object_type( 'location', 'product' );
}
add_action( 'init', 'reg_location_taxonomy', 0 ); 
Was it helpful?

Solution

You need add label vaue to following array

$labels = array(
    'name'              => _x( 'Locations', 'taxonomy general name' ),
    'singular_name'     => _x( 'Location', 'taxonomy singular name' ),
    'search_items'      => __( 'Search Locations' ),
    'all_items'         => __( 'All Locations' ),
    'parent_item'       => __( 'Parent Location' ),
    'parent_item_colon' => __( 'Parent Location:' ),
    'edit_item'         => __( 'Edit Location' ),
    'update_item'       => __( 'Update Location' ),
    'add_new_item'      => __( 'Add New Location' ),
    'new_item_name'     => __( 'New Location Name' ),
    'menu_name'         => __( 'Location' ),
);

like as follows

function reg_location_taxonomy() {
    register_taxonomy( 'location', array( 'product' ), array( 'hierarchical' => true, 'label' => $labels, 'singular_label' => 'Location', 'rewrite' => true ) );
    // register_taxonomy_for_object_type( 'location', 'product' );
}
add_action( 'init', 'reg_location_taxonomy', 0 ); 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top