[wp-hackers] Disable/ Stop "auto-draft" posts
johnbillion+wp at gmail.com
Tue Feb 28 17:12:10 UTC 2012
On 28 February 2012 16:50, Jeff Lambert <jeff.lambert at jvhm.com> wrote:
> As for having to create the post to get the PostID, why not just generate a
> PostID, put it into the Post form and then use it when the author saves the
> Post, as opposed to actually saving the Post first? I'm assuming there is a
> downside somewhere but it would remove the need to have auto drafts (for
> this purpose), remove the need to clean and remove some DB/comm overhead.
It's done this way so, for example, you have access to the $post
object for new posts before they've been saved. As for your
suggestion, you can only generate a valid post ID by inserting a row
into the posts table, which is what WordPress does.
On a similar note, WordPress used to generate post IDs for new posts
without inserting a row into the posts table. It generated negative
post IDs, which were then changed when the post was saved. The current
system is much more robust.
More information about the wp-hackers