WordPress function to run when a scheduled post is published, to change the modified date/time to match. Currently, it will only show the last saved data, not its published information, unless you modify it after publishing.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Scheduled posts should update modified date when published | |
function update_modified_date_to_post_date( $post ) { | |
$updated_data = [ | |
'ID' => $post->ID, | |
'post_modified' => $post->post_date, | |
'post_modified_gmt' => $post->post_date_gmt | |
]; | |
wp_update_post( $updated_data ); | |
} | |
add_action( 'future_to_publish', 'update_modified_date_to_post_date', 10, 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment