Skip to content

Instantly share code, notes, and snippets.

@nikitasinelnikov
Created May 25, 2023 06:49
Show Gist options
  • Save nikitasinelnikov/35a29b568273f7f99ec1a754b71e6a32 to your computer and use it in GitHub Desktop.
Save nikitasinelnikov/35a29b568273f7f99ec1a754b71e6a32 to your computer and use it in GitHub Desktop.
JobBoardWP: Change the job slug on insert post
function my_custom_date_add( $data, $postarr, $unsanitized_postarr, $update ) {
if ( 'jb-job' === $data->post_type ) {
$data->post_name = wp_date( 'Y-m-d', strtotime( $data->post_date ) ) . $data->post_name;
}
return $data;
}
add_filter( 'wp_insert_post_data', 'my_custom_date_add', 10, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment