Last active
August 29, 2015 14:16
-
-
Save aubreypwd/c6109ed817ed89e232c3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function ihcrs_wp_insert_post_data( $post_data, $postarr ) { | |
// Only on events (I have a function to do this...) | |
if ( ! ihcrs_is_event( $postarr['ID'] ) ){ | |
return $post_data; | |
} | |
// Get the current posts's data. | |
$previous_data = get_post( $postarr['ID'] ); | |
// If it's not a new post. | |
if ( $previous_data ) { | |
// Always force the date to remain the same. | |
$post_data['post_date'] = $previous_data->post_date; | |
$post_data['post_date_gmt'] = $previous_data->post_date_gmt; | |
} | |
return $post_data; | |
} | |
add_action( 'wp_insert_post_data', 'ihcrs_wp_insert_post_data', 99, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment