I tried out the answers above and the similar solution found here but was running into a problem where draft posts were still having their "Last Modified" date updated to the current time even though the published posts were updating correctly.
On our site, that was a catastrophic problem because we have thousands of draft posts saved and being updated caused them to all be pushed to the top of the post list by default, crowding out all the published posts that had been updated recently.
After restoring a backup of our site, I looked through the wp_update_post documentation but wasn't able to find much about the problem.
After some trial and error, I came up with this workaround code that successfully updates both draft and published posts without changing their "Last Modified" date. I'm not sure if all of the code below is necessary, but at least it seems to work.
function do_not_update_modified_date($new, $old)
{
$post_status = $new['post_status'];
if ($post_status === 'draft' || $post_status === 'pending' || $post_status === 'auto-draft')
{
$new_post_modified = $old['post_modified'];
if ((!empty($new_post_modified)) && ($new_post_modified !== '0000-00-00 00:00:00'))
{
$new_post_modified = substr($new_post_modified, 0, -1) . (intval(substr($new_post_modified, -1)) + 1) % 10;
}
$new['post_modified'] = $new_post_modified;
$new['post_modified_gmt'] = $new_post_modified;
}
else
{
$new['post_date'] = $old['post_date'];
$new['post_date_gmt'] = $old['post_date_gmt'];
$new['post_modified'] = $old['post_modified'];
$new['post_modified_gmt'] = $old['post_modified_gmt'];
}
return $new;
}
add_filter('wp_insert_post_data', 'do_not_update_modified_date'], 1, 2);
wp_update_post(['edit_date' => true, 'ID' => $post_id, 'post_name' => $new_post_name, 'post_title' => $new_post_title,]);
remove_filter('wp_insert_post_data', 'do_not_update_modified_date', 1, 2);
Warning: I haven't tested this on anything besides published posts and draft posts. I have no idea whether this will mess up any scheduled posts or create any other problems. Please take a backup before running this and check everything thoroughly afterwards.