I’m testing the capabilities of WordPress and trying to build a kind of back office/workflow system.
The basic principle is that each post will represent a job/spec that fall into certain categories etc etc… So far it’s working great, but I’m having trouble with generating sequential job numbers.
The idea is that when the user posts a spec, WP automatically generates a unique 4 digit ID that will represent the job number of that spec.
The current solution only works as far as generating id’s every time a post is called up in different categorised circumstances etc. What I want it to do is generate the number upon posting, then write to the database permanently rather than generate with the PHP.
Does anyone have a clue how I can do this?
Since you said you can’t use the WordPress post IDs, you could create a table that uses an AUTO_INCREMENT column to create and store them. After inserting a new entry there, you can retrieve the generated ID via PHP:
This way you can let MySQL handle the generation of IDs and leave PHP out of it.