admin管理员组文章数量:1416333
I have an array of image id's and i want assign them to the specific post:
foreach ($image_ids as $image_id)
var_dump(wp_insert_post(array('ID' => $image_id, 'post_parent' => $new_post_id), TRUE));
But there occurs error:
object(WP_Error)#252 (2) {
["errors"]=>
array(1) {
["empty_content"]=>
array(1) {
[0]=>
string(38) "Content, title, and excerpt are empty."
}
}
["error_data"]=>
array(0) {
}
}
So is it possible to update the post_parent
without updating other data?
I have an array of image id's and i want assign them to the specific post:
foreach ($image_ids as $image_id)
var_dump(wp_insert_post(array('ID' => $image_id, 'post_parent' => $new_post_id), TRUE));
But there occurs error:
object(WP_Error)#252 (2) {
["errors"]=>
array(1) {
["empty_content"]=>
array(1) {
[0]=>
string(38) "Content, title, and excerpt are empty."
}
}
["error_data"]=>
array(0) {
}
}
So is it possible to update the post_parent
without updating other data?
2 Answers
Reset to default 10Use wp_update_post()
, not insert
.
wp_update_post(
array(
'ID' => $image_id,
'post_parent' => $new_post_id
)
);
Just you need to give your category or parent name before the postname in Custom Structure section
本文标签: How to update post parent
版权声明:本文标题:How to update post parent? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745249231a2649721.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论