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?
Use
wp_update_post()
, notinsert
.Just you need to give your category or parent name before the postname in Custom Structure section