[wp-hackers] Best Practice for hooking wp_insert_post()
Kunal Bhalla
bhalla.kunal at gmail.com
Sun Jul 25 04:18:59 UTC 2010
I had to do that recently for my project -- create an 'activity' post when a
post of a particular type was published. As far as I remember,
wp_insert_post is called for everything, updating, whatever. I found it
simpler to hook into the transition post status (like nacin said), checking
that the post _was_ of the type I needed (automatically eliminating drafts,
auto-saves), whether the new status was publish, and that the old status
wasn't.
I've paste-binned the relevant bits of code here:
http://pastebin.com/z9SndiU5
Kunal
@kunalbhalla
More information about the wp-hackers
mailing list