A tool to enable posts on a wordpress blog to go to twitter

A tool to enable posts on a wordpress blog to go to twitter

Cool tool for adding links on your wordpress blog articles to enable them to quickly add a link to your blog article to their twitter account.


Adds a “Tweet This Post” link to every post and page. Shortens URLs in advance through, eating up only 19 of 140 characters. Also included: Plurk, Yahoo Buzz, Delicious, Digg, Ping.fm, Reddit, and StumbleUpon. Includes the post’s title after the link (can be customized). If your titles are really long, they get cut off at 136 characters with “…”. Customize under Settings > Tweet This. Includes your choice of six buttons.

NOTE: To upgrade from v1.0 – v1.2.3 to v1.3 – v1.3.9, deactivate Tweet This, delete the tweet-this folder, upload the new tweet-this folder, and reactivate Tweet This.

Normally, posting a link to Twitter takes up a lot of space. Though they shorten URLs with TinyURL, it doesn’t happen till after you post your tweet, so the length of the original URL takes away from your 140 characters.

While your readers might go to TinyURL.com, copy and paste the blog post’s permalink, shorten the URL, copy that new URL, go to Twitter, and paste it into the box, this plugin merges all that into one step, using the Twitter API and Th8.us, an external URL trimming service I created. I didn’t like how long TinyURL’s URLs are, so I made Th8.us. Its URLs are 19 characters instead of TinyURL’s 25, giving you more space to write about the blog post.

This plugin fetches a shortened URL from Th8.us for each of your blog posts’ permalinks server-side, then displays a link to Twitter for each post, with a small Twitter logo. This is done automatically for each post as needed, but the shortened URLs are cached (as a custom field in the postmeta table) to keep load times fast. The cached records are updated or deleted as needed when you edit a post’s permalink, delete a post, change your site’s permalink structure, or change URL services.

You can pick Adjix.com, bit.ly, h3o.de, hex.io, idek.net, is.gd, Lin.cr, Metamark.net, ri.ms, Snurl.com, Th8.us, TinyURL.com, Tweetburner.com, urlb.at, or Zi.ma as your short URL service. Or, you can use local URLs, like http://yourblog.com/?p=123.

Tweet This is extensible: you can edit the link text, tweet text, and popup title text under Settings > Tweet This, as well as restricting the links to single posts or pages. You can use these functions in your theme, within the loop:

tweet_this($service, $tweet_text, $link_text, $title_text, $icon_file,
$a_class, $img_class, $img_alt) : Echoes a Tweet This link. This is only
useful if you disable automatic insertion in the settings.  You can leave
the arguments blank like '' to use your settings from the options page.
These values are permitted for the $services argument: 'twitter', 'plurk',
'buzz', 'delicious', 'digg', 'ping', 'reddit', 'su'. The $icon_file
argument is for the filename of an image from the /tweet-this/icons/
folder. Example: tweet_this('twitter', '@richardxthripp [TITLE] [URL]',
'[BLANK]', 'Share on Twitter [[URL]]', 'tt-twitter-big3.png',
'tweet-this', 'tt-image', 'Post to Twitter'). $icon_file can be set to
"noicon" for a text-only link.

tweet_this_url($tweet_text) : Echoes the Tweet This URL, which is like
http://twitter.com/home/?status=Tweet+This+http://37258.th8.us by default.
Optional tweet_text argument overrides "Tweet / Plurk Text" from the
options menu. An example: tweet_this_url('@richardxthripp [TITLE] [URL]').

tweet_this_short_url() : Just echoes the short URL for the post
(Th8.us, TinyURL, etc.), cached if possible.

tweet_this_trim_title() : URL-encodes get_the_title(), truncates it at the
nearest word if it's overly long, and echoes.

tt_option($key) : like get_option(), but specifically for Tweet This'
settings. Useful for retrieving settings from the database.
Example: tt_option('tt_url_service').

You can prefix the first four of these functions with get_ to return the data without echoing, for further manipulation by PHP.

If you have a post or page for which you do not want a Tweet This link displayed, add a custom field titled "tweet_this_hide" with the value of “true”.

NOTE: On WordPress 1.5, you must go to Options > Tweet This and click “Save Options” before the Tweet This links will appear. Also: The “Tweets about this post” feature does not work on WordPress 1.5.

Copyright 2008-2009 Richard X. Thripp ( email : richardxthripp@thripp.com ) Freely released under Version 2 of the GNU General Public License as published by the Free Software Foundation, or, at your option, any later version