[wp-hackers] Best Practice for hooking wp_insert_post()

Mike Schinkel mikeschinkel at newclarity.net
Sat Jul 24 14:14:04 UTC 2010


Hi all:

I'd like to ask about best practices for hooking wp_insert_post().  The questions are when and why to use "save_post" vs. "wp_insert_post" and more importantly what's the best way to determine if a post is being added or updated, or is an auto-post? Actually, I'd love to have that all clarified.   

I came up with the following "artifacts" that imply to me it is in "insert" mode but I can't be sure:

$post->post_status=='auto-draft'
empty($post->guid)
empty($post->post_name)

Thanks,

-Mike


More information about the wp-hackers mailing list