Skip to main content

Timeline for Get the post_id of a new post

Current License: CC BY-SA 3.0

9 events
when toggle format what by license comment
Apr 24, 2012 at 17:50 comment added Adam save_post and wp_insert_post we're creating folder-ID entries every-time I touched either Add New post or Update or Publish. So simply adding a post then publishing it would create two folders with incremented IDs (one correct and one-incorrect) and similarly if you updated the post you'd get another folder with another ID. post_updated being the only action that committed the official ID once and once only. I'll be looking further into understanding the mechanism behind how WP handles IDs in relation to the former actions too because I don't really get it after this experiment. Enjoy!
Apr 24, 2012 at 13:08 vote accept roberthuttinger
Apr 24, 2012 at 13:08 comment added roberthuttinger Had a chance to test it, perfect! The post_updated must have been the correct thing to tap into. Now to do some homework onthe differences between save_post, post_save, and post_updated thanks!
Apr 24, 2012 at 2:33 comment added Adam I hope that clears things up for you... Let us know how you get on.
Apr 24, 2012 at 2:32 comment added Adam Easy? Are you implying that I somehow might be turning over tables and breaking my keyboard because you won't mark this answer? :) - I'm not that invested believe me so don't read into my message as anything other than a question and a re-statement of an answer which is directly related to your question because your first comment to me is confusing as you say it will work yet doesn't solve the issue yet it directly addresses the issue. My follow up to that is an attempt to gain some clarification that we're on the same page so I can continue to help you until you have solved this problem
Apr 24, 2012 at 0:01 comment added Adam @roberthuttinger I'm confused, how does this not solve the issue? You want to get the post_id of a new post and create a directory such as - /path/bla/uploads/post-id/ - the above code does exactly that.
Apr 23, 2012 at 20:32 history edited Adam CC BY-SA 3.0
added 188 characters in body
Apr 23, 2012 at 20:24 history edited Adam CC BY-SA 3.0
added 3 characters in body
Apr 23, 2012 at 19:54 history answered Adam CC BY-SA 3.0