我使用以下代码向 Woocommerce 添加了一个名为“供应商”的新分类法:
// hook into the init action and call taxonomy when it fires
add_action( 'init', 'create_vendor_taxonomy', 0 );
// create and register vendor taxonomy (hierarchical)
function create_vendor_taxonomy() {
$labels = array(
'name' => _x( 'Vendors', 'taxonomy general name', 'textdomain' ),
'singular_name' => _x( 'Vendor', 'taxonomy singular name', 'textdomain' ),
'search_items' => __( 'Search Vendors', 'textdomain' ),
'all_items' => __( 'All Vendors', 'textdomain' ),
'parent_item' => __( 'Parent Vendor', 'textdomain' ),
'parent_item_colon' => __( 'Parent Vendor:', 'textdomain' ),
'edit_item' …Run Code Online (Sandbox Code Playgroud)