Integrating Twitter with WordPress

I wanted to integrate Twitter tweets as Asides into another blog I was setting up. The excellent Twitter Tools from did exactly what I wanted except that the posts created had comments and trackbacks (pings) open. There was no option to default the comments/trackback status.

I wanted comments and trackbacks for Asides to be closed for now, so a quick hack was in order. I suppose I could have added new options to make this configurable but I was too lazy. :p


  1. Backup your original copy of twitter-tools.php.
  2. Open up twitter-tools.php in the plugin editor.
  3. Look for this snippet , 'post_status' => 'publish' and add these 2 lines after that. I had to add the lines twice, once for the function do_tweet_post and another time for the function do_digest_post.

    , 'comment_status' => 'closed'
    , 'ping_status' => 'closed'

Example for function do_tweet_post (additions at lines 10-11):

  1. function do_tweet_post($tweet) {
  2.     global $wpdb;
  3.     remove_action(‘publish_post’, ‘aktt_notify_twitter’);
  4.     $data = array(
  5.         ‘post_content’ => $wpdb->escape($tweet->tw_text)
  6.         , ‘post_title’ => $wpdb->escape(trim_add_elipsis($tweet->tw_text, 30))
  7.         , ‘post_date’ => get_date_from_gmt(date(‘Y-m-d H:i:s’, $tweet->tw_created_at))
  8.         , ‘post_category’ => array($this->blog_post_category)
  9.         , ‘post_status’ => ‘publish’
  10.         , ‘comment_status’ => ‘closed’
  11.         , ‘ping_status’ => ‘closed’
  12.     );
  13.     $post_id = wp_insert_post($data);
  14.     add_post_meta($post_id, ‘aktt_twitter_id’, $tweet->tw_id, true);
  15.     add_action(‘publish_post’, ‘aktt_notify_twitter’);
  16. }

The code is provided as-is, with absolutely no warranties, so please don’t blame me if something disastrous happens. Backup backup backup.

Tags: , ,