Automatically provide ShortURL for your WordPress blog posts
Automatically provide shorturls for your WordPress blog posts
Are you on Twitter? I am. This service make an intensive use of shorturls in order to reduce the size of urls. Why not provide automatically provide a shorturl 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 getsUrl($url) {
$surl = file_get_contents(“http://s.jar.io/api.php?url=”.$url);
return $surl;
}
On your single.php file, paste the following within the loop:
< ?php $turl = getsUrl(get_permalink($post->ID));
echo ‘ShortURL: < a href=”’.$turl.’”>‘.$turl.’< /a>‘
?>