‘Tweet This’ Using TinyURL and NO Plugin v2.0
Version 1.0 of “Tweet This Without a Plugin” was pretty awesome, but it wasn’t perfect.
You see, I quickly realized that it doesn’t auto-shrink the URL when thrown up into Twitter, which made you lose a lot of valuable tweet space.
So, I set out to create a little code that would auto-TinyURL the permalink without the use of a bloated WordPress plugin (and trust me, the plugins you use for Tweeting your posts is bloated and heavy).
So, instead of the above you get this nicely shrunk link:

So here’s how to do it: First you goto your functions.php file and add the following code:
function getTinyUrl($url) { $tinyurl = file_get_contents(“http://tinyurl.com/api-create.php?url=”.$url); return $tinyurl; }
Here’s an image of how mine looks:

Then, you goto your single.php file and add the following code inside the content loop:
<?php $turl = getTinyUrl(get_permalink($post->ID)); ?>
<li><a href=’http://twitter.com/home?status=@Human3rror Blogged <?php echo ”.$turl.” ?>’ target=’_blank’>Tweet This Post on Twitter!!!</a></li>
The bolded text is what you can change without breaking the function call.

Pretty cool, huh? It’s actually quite easy! Gives your blog the “Tweet This” functionality without the additional weight of a plugin.
Nice.
What does mine look like? Just look right below this sentence. Why don’t you hit it for good luck? ![]()
















Thanks for sharing this!
How cool! When I can sit and focus on how to implement this (read: when I'm not crazy-busy at work) I will do it!
I'm not a wiz by any means when it comes to this php stuff here's what I'm looking at in my functions.php (courtesy of the simpl3 theme)
<?php
if ( function_exists('register_sidebar') )
register_sidebar(array(
'name' => 'Right Sidebar',
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
?>
Where might you place it in that bit of code?
right before "if".
Hmm, I keep getting syntax errors.
Nice work, man! Love it!
doh…!
Nice one. Gonna put that into the blog I am preparing
sweetness!love learning new ninja tricks
me likey
ummmmmmmm – u only follow 34 Tweeps?
that is a lot of self discipline.
Awesome… Added this functionality to my blog last night!!
WOW! Great idea bro. I never even thought about this before. Im gonna go try this on my blog now. Thanks for sharing!
got it working! It took a while because I kept getting some errors. I had to retype the quotes into the code put into the funtctions.php and it worked. Thanks again!
SWEET!
Looks like you're not using tinyurl.com anymore, huh? The "Tweet this" link now gives the "ugly WordPress permalink" version: http://human3rror.com/?p=2627. That seems like a better way to go, in my opinion, as long as your domain name is relatively short.
Yeah. I did that purposely…!
Cool. Seems like a better system to me, since it's built right into WordPress.
Is that why you were tweeting about it earlier?
i was shooting it over to @michaelhyatt… it was supposed to be a DM…
uaha.
apMWfR dkv7Rq29nVvzm74lApqSw
Thanks man, worked beautifully!