我创建了名为Locations的自定义分类法,一切正常,但每当我添加分类法时,无处不在显示分类名称为Category而不是Location,Like Add New category
等等,在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 );
答案 0 :(得分:2)
您需要将标签值添加到以下数组
$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' ),
);
如下所示
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 );