我想插入如下类别:
A类
第1子类第2子类第3子类谢谢
这是我的密码
$term = wp_insert_term(
$row[11],
\'product_cat\',
[
\'description\' => \'FooBar Category description\',
\'slug\' => $row[11]
]
);
if(is_wp_error($term)) {
$term_id = $term->error_data[\'term_exists\'] ?? null;
} else {
$term_id = $term[\'term_id\'];
}
$term1 = wp_insert_term(
$row[12],
\'product_cat\',
array(
// what to use in the url for term archive
\'slug\' => $row[12],
// link with main category. In the case, become a child of the "Category A" parent
\'parent\' => term_exists($row[11], \'product_cat\')[\'term_id\']
)
);
$term2 = wp_insert_term($row[13], \'product_cat\',
array(
// what to use in the url for term archive
\'slug\' => $row[13],
// link with main category. In the case, become a child of the "Category A" parent
\'parent\' => term_exists($row[12], \'product_cat\')[\'term_id\']
)
);