‘Tweet This’ Using TinyURL and NO Plugin v2.0

tweetthiswithnopluginv1 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.


What does mine look like? Just look right below this sentence. Why don’t you hit it for good luck? :)