WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 3 down vote accepted

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 in wp_transition_post_status() and happens only one time. You get the $post object as argument.

Prototype, not tested:

add_action( 'draft_to_publish', 'wpse_55516_tweet_new_post' );

function wpse_55516_tweet_new_post( $post )
    if ( 'post' !== $post->post_type )

    // Tweet it like a boss …
share|improve this answer
Nice!!!... that looks like the one. Yeah that was something I overlooked: how annoying it would be for followers to get get the tweet every typo change.. I'll give it a try now.. – Alex Jun 17 '12 at 10:12
that's the one!! – Alex Jun 17 '12 at 10:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.