Set Attachment Image File URL as GUID
I have a form that uploads images and i want to update the GUID to be the attachment file url after WP generates the metadata.
I tried to use wp_update_post
, but seems that is not updating the guid
.
$attachments = get_posts($post_data);
if ($attachments) {
// attach images to gallery
foreach ($attachments as $attachment) {
wp_update_post(array(
'ID' = $attachment-ID,
'post_status' = 'inherit',
'post_parent' = $gallery_post_id,
'guid' = wp_get_attachment_url($attachment-ID);
)
);
}
}
Any suggestions ?
Topic wp-update-post guids attachments Wordpress
Category Web