Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function update_modified_date_on_publish($new_status, $old_status, $post) {
- // Only update if transitioning from 'future' (scheduled) to 'publish'
- if ($old_status === 'future' && $new_status === 'publish') {
- // Update the post's modified date to match the published date
- wp_update_post(array(
- 'ID' => $post->ID,
- 'post_modified' => current_time('mysql'),
- 'post_modified_gmt' => current_time('mysql', 1),
- ));
- }
- }
- add_action('transition_post_status', 'update_modified_date_on_publish', 10, 3);
Advertisement
Add Comment
Please, Sign In to add comment