DISCLAIMER: this post is older than one year and may not be up to date with latest WordPress version.

Are you on Twitter? I am. This service make an intensive use of tinyurls in order to reduce the size of urls. Why not provide automatically provide a tinyurl to your readers so they can use it on Tweeter?

To achieve this recipe, simply open your functions.php file and paste the following code:

function getTinyUrl($url) { 
    $tinyurl = file_get_contents("http://tinyurl.com/api-create.php?url=".$url); 
    return $tinyurl; 

On your single.php file, paste the following within the loop:

$turl = getTinyUrl(get_permalink($post->ID)); 
echo 'Tiny Url for this post: <a href="'.$turl.'">'.$turl.'</a>'

Great, isn’t it? Have a good week end everyone!

Leave a Comment

Your email address will not be published. Required fields are marked *