[wp-hackers] Best Practice for hooking wp_insert_post()
Mark E
mark at simplercomputing.net
Sat Jul 24 18:49:38 UTC 2010
On 07/24/2010 08:14 AM, Mike Schinkel wrote:
> 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.
If I remember right, auto-draft is a copy of post saved automatically
while the WP post screen is open, and that particular save process is
driven by Javascript.
You can use wp_insert_post() to add post content, build an array of
parameters and pass it to the function and if the post is saved
successfully a post ID number is returned.
If you look at the code for the function in wp-includes/post.php you'll
see an array of default parameters.
Mark
More information about the wp-hackers
mailing list