I have some functionality I’ve written in order to post the title and link for the post to twitter whenever a post is published.
I’m wondering which wp function to hook this to? save_post has no real reference documentation. Basically I just want to run an action when a post is successfully published.
Thanks very much.
You could hook into
publish_post
like the plugin Inform about Content does.But this hook is fired on updates to published posts too, this may result in many redundant tweets â¦
Try
'draft_to_publish'
instead. It is called inwp_transition_post_status()
and happens only one time. You get the$post
object as argument.Prototype, not tested: