0
我在提交页面中使用下面的代码。不能保存自定义分类的自定义类别
$new_post = array(
'post_title' => $title,
'post_content' => $description,
'post_excerpt' => $excerpt,
'post_category' => array($_POST['cat']),
'tags_input' => array($tags),
'post_status' => 'publish',
'post_type' => 'custom_post_type'
);
$pid = wp_insert_post($new_post);
$_POST['cat']
获取正确的`category id。我的自定义分类法被命名为目录。
我可以在后端的已保存文章中查看,但checkbox
未在此处被选中,而在前端,我在这些自定义类别下显示帖子,但未显示。
是否有办法正确保存自定义分类的自定义类别。
感谢该诀窍,谢谢你救了我的时间...... –
@欢迎您user2938305,很高兴它帮助。请接受为答复。 – wesamly