【发布时间】:2017-01-29 14:55:29
【问题描述】:
我正在使用 wp_insert_post 添加分类为“product_cat”的 woocommerce 产品。这是我的代码。
首先我添加一个新产品。
$post_id = wp_insert_post( array(
'post_title' => 'My Title',
'post_content' => 'This is custom template',
'post_status' => 'publish',
'post_type' => "product",
) );
在这里,我在该帖子中附加了条款
wp_set_post_terms( $post_id, array(12,13), 'product_cat' );
但是在商店页面上,当我单击添加产品的特定类别时,该产品未显示在该类别中,但在后端(wp 管理员)上,我看到这些条款已附在我的产品中。
【问题讨论】:
标签: wordpress woocommerce categories taxonomy custom-taxonomy