Skip to content

Instantly share code, notes, and snippets.

@aubreypwd
Last active August 29, 2015 14:16
Show Gist options
  • Save aubreypwd/c6109ed817ed89e232c3 to your computer and use it in GitHub Desktop.
Save aubreypwd/c6109ed817ed89e232c3 to your computer and use it in GitHub Desktop.
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