Inspiration For Creative Minds
Home » Labs » How to get tiny Urls for WordPress automatically  

Filed under Labs

URL shortening is an important part when you play blogs with social media. You can get short url in two ways first is a third party services like and other is using of a WordPress Plugin. Here we are going to make short urls by first method, that is using For doing this place below codes on appropriate places of your WordPress theme as described below.

Add to functions.php

function getTinyUrl($url) {
    $tinyurl = file_get_contents("".$url);
    return $tinyurl;

Add to single.php

	$turl = getTinyUrl(get_permalink($post->ID));
	echo 'Tiny Url for this post: <a href="'.$turl.'">'.$turl.'</a>'
It's only fair to share...Share on Google+Tweet about this on TwitterShare on Facebook

Posts you may like: