如果像我一样使用, WordPress MU 要建立一个平台,需要限制每个博客的商品分类数量:
add_filter('pre_insert_term', function($term, $taxonomy){if($taxonomy == 'product_category'){if(wp_count_terms($taxonomy) > 10){return new WP_Error('too_much_product_category', 商品分类上限为:10。');}}return $term;}, 10, 2);
使用上述代码后,再加上商品分类,就会出现: