TinyURL Link: How To Automatically Get One For Your Blog Posts

StevenWordPress

Mostly pushed by the rapid growth of Twitter (and its 140 characters limit), url shorteners business has also exploded. There are plenty of reason for you to need some shortened urls for your blog posts… Having shorter links to share on Twitter is only a small example.

In order to automatically generate TinyURL shortlinks, first, you need to add the following code to your functions.php file:

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

Learn how I made $33,543 online in the past 12 months.

Simply input your best email below to get started.

The next step is to edit single.php in your theme folder and paste the following code (within the loop):

<?php
$tinyurl = getTinyUrl(get_permalink($post->ID));
echo 'TinyURL link for this post: <a href="'.$tinyurl.'">'.$tinyurl.'</a>';
?>

Learn how I made $33,543 online in the past 12 months.

Simply input your best email below to get started.

Learn how I made $33,543 online in the past 12 months.

Simply input your best email below to get started.

No thanks, I have enough money