function preserve_post_author_on_update($data, $postarr) {
if (!empty($postarr[‘ID’])) {
$original_post = get_post($postarr[‘ID’]);
$data[‘post_author’] = $original_post->post_author;
}
return $data;
}
add_filter(‘wp_insert_post_data’, ‘preserve_post_author_on_update’, 10, 2);
This code prevents WordPress from automatically changing the original author when a post is updated, especially when editing synchronized patterns or reusable blocks. It ensures the post author remains the same, even after updates.By default, WordPress changes the post author to the current user when a post is updated. So Add this code in functions.php.