将下述代码添加到functions.php:
- function sl_taxonomies_product() {
- $labels = array(
- ‘name’ => _x( ‘产品分类’, ‘taxonomy general name’ ),
- ‘singular_name’ => _x( ‘产品分类’, ‘taxonomy singular name’ ),
- ‘search_items’ => __( ‘搜索产品分类’ ),
- ‘all_items’ => __( ‘产品的全部分类’ ),
- ‘parent_item’ => __( ‘父级分类’ ),
- ‘parent_item_colon’ => __( ‘父级分类:’ ),
- ‘edit_item’ => __( ‘编辑产品分类’ ),
- ‘update_item’ => __( ‘更新产品分类’ ),
- ‘add_new_item’ => __( ‘添加产品分类’ ),
- ‘new_item_name’ => __( ‘新的产品分类’ ),
- ‘menu_name’ => __( ‘产品分类’ ),
- );
- $args = array(
- ‘labels’ => $labels,
- ‘hierarchical’ => true,
- );
- register_taxonomy( ‘product_category’, ‘product’, $args );
- }
- add_action( ‘init’, ‘sl_taxonomies_product’, 0 );
即可在产品菜单下有个产品分类的二级菜单:
Leave a Reply