接受了建议,决定不重新发明轮子。创建了特定于产品的分类法,称为产品类别。在我的函数中添加了以下代码。php。
add_action(\'init\', \'products_categories\', 0);
function products_categories(){
$labels = array (\'name\' => _x(\'Product Categories\',\'taxonomy general name\'),
\'singular_name\' =>_x(\'Product Category\',\'taxonomy singular name\'),
\'serch_items\' => __(\'Search Product Categories\'),
\'popular_items\' => (\'Popular Product Categories\'),
\'all_items\' => __(\'All Product Categories\'),
\'parent_item\' => null,
\'parent_item_colon\' => null,
\'edit_item\' => __(\'Edit Product Category\'),
\'update_item\' => __(\'Update Product Category\'),
\'add_new_item\' => __(\'Add Product Category\'),
\'new_item_name\' => __(\'New Product Category\'),
\'separate_items_with_commas\' => __(\'Seperate Product Categories with commas\'),
\'add_or_remove_items\' => __(\'Add or remove Product Categories\'),
\'choose_from_most_used\' => __(\'Most Used Product Categories\'),
\'menu_name\' => __(\'Product Categories\'),
);
register_taxonomy(\'product_categories\', \'products\', array(
\'hierarchical\' => false,
\'labels\' => $labels,
\'show_ui\' => true,
\'show_admin_column\' => true,
\'update_count_callback\' => \'_update_post_term_count\',
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => \'product_category\' ),
));
}
现在我所要做的就是重新培训我的员工,重写我的一些内部脚本,并重做我的查询T\\T