Why wp_update_post() does not update GUID?

Trying to update GUID on a attachment using the wp_update_post() function but its not updating GUID nor its throwing any error.

Example code:

$post = [
    'ID'   = 45,
    'guid' = 'https://example.com/foo.png'
];
    
wp_update_post($post);

Topic wp-update-post Wordpress

Category Web


Turns out WordPress do not recommend updating GUID thus its disallowed.

But we can update it using sql query:

global $wpdb;
$wpdb->update($wpdb->posts, ['guid' => $newGUID], ['ID' => $postID]);

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.