[wp-hackers] How find the correct post_id to save.
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>
>>> I need to add update a separate database table when I write a post so I
>>> 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
>>> post and I only want to create a database entry for the "real" (parent)
>>> 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
>>> 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
More information about the wp-hackers