How to prevent WordPress from updating the modified time?

The question of how to customize which post data gets updated has been answered elsewhere on StackExchange.

Here is a specific example of how to stop the modified date from being updated:

function stop_modified_date_update( $new, $old ) {
    $new['post_modified'] = $old['post_modified'];
    $new['post_modified_gmt'] = $old['post_modified_gmt'];
    return $new;
}

add_filter( 'wp_insert_post_data', 'stop_modified_date_update', 10, 2 );

// do stuff that updates post(s) here

remove_filter( 'wp_insert_post_data', 'stop_modified_date_update', 10, 2 );

NB: It is extremely important to remove the filter when you’re done with your special tasks unless you really want the modified date to never update anywhere on the site.

Happy coding!

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)