I have a custom post type called 'Customers'. Data is taken using a front end form, which is then saved into the post type. But I want the titles to be automatically generated as unique incremental numbers. Meaning, it will go as 1,2,3,4..
I got most of this figured out, except a small issue. If there are no posts, then the new title will be 1. If there are posts, then code will fetch the most recent one, check it's title and generate new title by increasing it by 1. So far so good.
But if I delete the most recent post, new post added after that will be assigned same title # as the last one. Also, if I delete all posts, titles will start again from #1. I don't want any of the titles to repeat, no matter if any or even all of previous posts are deleted. I want them to always be go on incrementing, never assign the same # again.