How to update post parent?

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:

Read More
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?

Related posts

Leave a Reply

2 comments