How to run a code snippet ONLY when a post is created, not when updated
-
I have a custom post type called “Clients”.
And a custom field “Client ID” (integer)The first time a new Client record is created, I want WordPress
to loop through all the Client records created so far, find the highest “Client ID” value, increment it by “1”, then save that value into the Client ID field.So far, so good.
But anytime somebody goes back and “updates” this post, it will generate a new Client ID value. Not good.
So the solution would seem to be, to limit the “loop, increment, save” function to only happen when the post is first created, and NOT when the post is updated.
Any ideas how to do that?
Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
- The topic ‘How to run a code snippet ONLY when a post is created, not when updated’ is closed to new replies.