2017-04-05 128 views

回答

0

提供你有term_id是为了你们的类别(即与get_term_by),你可以这样做:

wp_set_object_terms($post_id, [$category->term_id, $sub_category->term_id], 'product_cat'); 
0

您需要的产品ID添加到表term_relationships。为此,您需要从“term_taxonomy”表中获得“term_taxonomy_id”。

因此,在term_relationships中,object_id =从term_taxonomy表中找到的product_ID和term_taxonomy_id。

您可以通过这种方式为产品分配任何类别/子类别。

相关问题