0

我已经创建了名为 Locations 的自定义分类法,一切正常,但是每当我添加分类法时,到处都将分类法名称显示为类别而不是位置,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 ); 
4

1 回答 1

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 ); 
于 2013-08-05T15:41:06.583 回答