导入文章时的Wordpress自定义分类法



我目前正在从外部源导入帖子,并在产品自定义帖子类型中导入它们。我正在尝试使用自定义分类法导入它们。

'post_title' => wp_strip_all_tags($result->Product_Name) ,
'meta_input' => array(
'Coupon_start_date' => $result->Coupon_start_date,
'Coupon_end_date' => $result->Coupon_end_date,
'New_Price' => $result->New_Price,
'Old_Price' => $result->Old_Price,
'tax_input' => array($category->'Store_Type' => array($category->'StoreA' )),
) ,
'post_type' => 'product',
'post_status' => 'publish',
);
wp_insert_post($cupon);
$pid = wp_insert_post($cupon);

分类法蛞蝓是'Store_Type',其中我有StoreA和StoreB。我试了所有可行的办法,但就是想不出来。

'post_title' => wp_strip_all_tags($result->Product_Name) ,

'meta_input' => array(
'Coupon_start_date' => $result->Coupon_start_date,
'Coupon_end_date' => $result->Coupon_end_date,
'New_Price' => $result->New_Price,
'Old_Price' => $result->Old_Price,
'tax_input' => array($category->'Store_Type' => array($category->'StoreA' )),
) ,
'post_type' => 'product',

'post_status' => 'publish',

这是您要传递的创建新帖子的参数数组吗?如果是,则数组中存在错误。您已经在'meta_input'数组中添加了'tax_input'键。你可以尝试使用下面的参数array.

'post_title' => wp_strip_all_tags($result->Product_Name) ,
'meta_input' => array(
'Coupon_start_date' => $result->Coupon_start_date,
'Coupon_end_date' => $result->Coupon_end_date,
'New_Price' => $result->New_Price,
'Old_Price' => $result->Old_Price,
) ,
'tax_input' => array($category->'Store_Type' => array($category->'StoreA' )),
'post_type' => 'product',
'post_status' => 'publish',

希望对你有用。

最新更新