[wp-hackers] How find the correct post_id to save.

Otto otto at ottodestruct.com
Mon Dec 8 22:47:49 GMT 2008

Be careful though, of the autosave case. Until the post is autosaved
that first time, it has no ID. In which case, the $_POST['post_ID'];
will not be set.

On Mon, Dec 8, 2008 at 4:35 PM, Mikael Hedengren <mikael at cylinderlabs.se> wrote:
> Hi Otto,
> Thanks, you saved me a lot of grief!
> On Mon, Dec 8, 2008 at 2:50 PM, Mikael Hedengren <mikael at cylinderlabs.se>
> wrote:
>>> I need to add update a separate database table when I write a post so I
> use
>>> add_action('save_post', ...) to get the data to save.
>>> The problem is that I get two calls with different postID:s when I save
> the
>>> post and I only want to create a database entry for the "real" (parent)
> post
>>> but I don't know how to find that out.
>>> Can anybody tell me how to get the correct postID or is there a better
> way
>>> to link to the correct post from my database table?
>>$post_id = (int) $_POST['post_ID'];
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers

More information about the wp-hackers mailing list