There is an issue with the code above.
It created sequential numbers by counting posts in specific post type. But when I remove an entry of this post type, the numbering is starting to make similar numbers which is mess up the thing.
Can you please suggest me a way or idea to prevent this confliction?
Thank you!
Thank you for your response.
This method worked to me:
add_filter( 'wp_insert_post_data' , 'odin_prj_title' , 10, 2 );
function odin_prj_title( $data , $postarr )
{
if( $data['post_type'] == 'prj' && $data['post_status'] != 'publish' ) {
$count_posts = wp_count_posts('prj');
$published_posts = $count_posts->publish;
$data['post_title'] = 'P0' . ($published_posts + 1);
}
return $data;
}
https://wordpress.stackexchange.com/posts/296509/revisions
Actually I only need one custom field which it increment sequentially. The links could stay like that:
example.com/invoice/55/
example.com/invoice/57/
example.com/invoice/59/
example.com/invoice/61/
Can you please guide me how can I do this?
Thank you in advance!