I just started (again) using the TwitterTools plugin for WordPress to post individual tweets directly to my blog. Problem is, I wasn’t happy with the way the tweets were being displayed — raw and unstyled, and with no linkback to the status page on Twitter. When you use the post-to-digest feature it does have the linkback, and it’s easy to style because you can target the enclosing list element. So I wanted to copy those two features over for the individual tweet-to-blog posts. So I hacked that plugin into shape! I’ll post the steps I took in case it comes in handy for someone else.

(If you try this fix, I hope it works for you. But be aware that I’m NOT a plugin coder; I don’t actually know what I’m doing. So proceed at your own risk!)

The following instructions apply to TwitterTools v1.2b1, available in a zip-file here.

First, back up your files in case something goes horribly wrong! Then, open twitter-tools.php and find the “do_tweet_post” section, starting around line 272. It’ll look like this:

function do_tweet_post($tweet) {
    global $wpdb;
    remove_action('publish_post', 'aktt_notify_twitter');
    $data = array(

(etc. etc.)

Now you’ll make a new variable to display the tweets the way you want. I called my variable “tweetcontent” but you can call it something else if you like. Also, in my case I’m using an unordered list to mark up each tweet, even though there’s only one tweet per post. You don’t have to do that though, you can use whatever style-related tags you want.

So! Insert the following lines just before the last line (the $data one):

$tweetcontent .= '<ul>'."\n";
$tweetcontent .= '<li>'.aktt_make_clickable($tweet->tw_text).' <a href="http://twitter.com/'.$this->twitter_username.'/statuses/'.$tweet->tw_id.'">#</a></li>'."\n";
$tweetcontent .= '</ul>'."\n";

(You can also add a class name to the ul or the li; that’s how I style my tweets.)

So in the end the function will look like this:

function do_tweet_post($tweet) {
global $wpdb;
remove_action('publish_post', 'aktt_notify_twitter');
$tweetcontent .= '<ul>'."\n";
$tweetcontent .= '<li>'.aktt_make_clickable($tweet->tw_text).' <a href="http://twitter.com/'.$this->twitter_username.'/statuses/'.$tweet->tw_id.'">#</a></li>'."\n";
$tweetcontent .= '</ul>'."\n";
$data = array(

(etc. etc.)

One last thing. Please change the very next line:

'post_content' => $wpdb->escape(aktt_make_clickable($tweet->tw_text))

…to the following:

'post_content' => $wpdb->escape($tweetcontent)

(“tweetcontent” can be whatever variable name you used earlier, if you changed it.)

Save the plugin file and you’re done. Yup! You’re welcome. ;-) Feel free to post a comment if you did or didn’t get it working, or if you have any other TTTs to share.