One solution among others :
In a plugin, you create an option on it’s activation in order to store your sequence number :
/*
Plugin Name: Reservation Increment
Description: test
*/
/**
*
* Name : myplugin_activate
* Description : Activation function
*
* @params
* @return
*
**/
function myplugin_activate() {
update_option('reservation_increment',3000);
}
register_activation_hook( __FILE__, 'myplugin_activate' );
Now you have to update that value and associate it with your new CPT when you create a new reservation :
/**
*
* Name : update_reservation_sequence
* Description : Updates the reservation unique incremential number
*
* @params
* @return
*
**/
function update_reservation_sequence ($post_id, $post, $update){
$slug = 'reservation_cpt';
// If this isn't a 'reservation_cpt' post, don't update it.
if ( $slug != $post->post_type || $update) {
return;
}
$increment = get_option('reservation_increment') +1;
if ( ! add_post_meta( $post_id, 'reservation', $increment, true ) ) {
update_post_meta ( $post_id, 'reservation', $increment );
}
update_option('reservation_increment',$increment);
return;
}
add_action( 'save_post', 'update_reservation_sequence',10,3 );
And then, to access it in your single-reservation.php template :
echo "<p>Reservation number : ".get_post_meta( get_the_ID(), 'reservation', true )."</p>";
Hope this will help !