我正在为我创建的自定义帖子类型构建一些自定义分类法。
自定义帖子类型为Products
. 对于自定义帖子类型Products
我创建了Category
. 现在处于Category
, 我想对Sub_Category
. 我已经创建了所有分类法并将它们设置为层次结构,但是Sub_Category
税收似乎与Product
自定义帖子类型,而不是Category
自定义分类法。有没有办法做到这一点?我看到一个屏幕截图,有人在为他们创建的分类法填写分类表,它有一个家长选项,但我从来没有看到过。如何选择家长Category
我的分类SubCategory
分类学
这是我的Category
和SubCategory
分类代码:
function create_productcategory_taxonomy() {
$labels = array(
\'name\' => _x( \'Categories\', \'taxonomy general name\' ),
\'singular_name\' =>_x( \'Category\', \'taxonomy singular name\' ),
\'search_items\' => __( \'Search Categories\' ),
\'popular_items\' => __( \'Popular Categories\' ),
\'all_items\' => __( \'All Categories\' ),
\'parent_item\' => null,
\'parent_item_colon\' => null,
\'edit_item\' => __( \'Edit Product Category\' ),
\'update_item\' => __( \'Update Product Category\' ),
\'add_new_item\' => __( \'Add New Product Category\' ),
\'new_item_name\' => __( \'New Product Category\' ),
\'separate_items_with_commas\' => __( \'Separate categories with commas\' ),
\'add_or_remove_items\' => __( \'Add or remove product categories\' ),
\'choose_from_most_used\' => __( \'Choose from the most used categories\' )
);
register_taxonomy(\'tf_productcategory\', \'tf_products\', array (
\'label\' => __(\'Product Category\'),
\'labels\' => $labels,
\'hierarchial\' => true,
\'show_ui\' => true,
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => \'product-category\'),
));
}
function create_product_subcategory_taxonomy() {
$labels = array(
\'name\' => _x( \'SubCategories\', \'taxonomy general name\' ),
\'singular_name\' =>_x( \'SubCategory\', \'taxonomy singular name\' ),
\'search_items\' => __( \'Search SubCategories\' ),
\'popular_items\' => __( \'Popular SubCategories\' ),
\'all_items\' => __( \'All SubCategories\' ),
\'parent_item\' => __( \'Main Category\' ),
\'parent_item_colon\' => ( \'Main Category:\' ),
\'edit_item\' => __( \'Edit Product SubCategory\' ),
\'update_item\' => __( \'Update Product SubCategory\' ),
\'add_new_item\' => __( \'Add New Product SubCategory\' ),
\'new_item_name\' => __( \'New Product SubCategory\' ),
\'menu_name\' => __( \'SubCategories\' )
);
register_taxonomy(\'tf_productsubcategory\', \'tf_products\', array (
\'label\' => __(\'Product SubCategory\'),
\'labels\' => $labels,
\'hierarchial\' => true,
\'show_ui\' => true,
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => \'product-subcategory\'),
));
}
add_action( \'init\', \'create_productcategory_taxonomy\', 0 );
add_action( \'init\', \'create_product_subcategory_taxonomy\', 0 );