Skip to main content
2 of 2
added 168 characters in body

Give a unique ID while saving

I have in my theme custom post types (products) with some meta-boxes. My client asked me, to automaticly give a unique SKU (meta-box) while saving that product.

My thought:

Give a random ID => have to check if that ID somewhere else exists OR

Give the Post-ID => that is just possible after saving once, cuz WP assign that ID while saving.

@Milo "additionally, a new post already has an ID before the user saves the post" How can I get the ID before I save the post and put it into that meta box and save it with a new post at once?

Thanks