How To Add Automatic Short URLs In WordPress

Short URL’s have become big business across the worldwide web, Google, Twitter and Digg for example all have their own, and you then have the big boys of short URL such as and

I recently wrote a Tutorial over on WPzine which covers making automatic short URLs in your posts for your readers to share. I then spoke to the brains of Nenuno (Daniel) and he mentioned urls. is a service run by Stumbleupon which shortens your URLs but can do so using your own domain too, the beauty of this service is your URL is syndicated to StumbleUpon, Facebook, and Twitter once you shorten the URL.

A side effect of this for example; here at Nenuno one of our links got over 1000 views as a result of the short URL, see below:

A graph showing how can help boost traffic

Quick Tutorial

So today I will show you a easy way to auto shorten your WordPress URLs using the API, you will be working in your functions.php and single.php file, please backup before making any changes!

Open functions.php and add:

function getsupr($url) {
$supr = file_get_contents("".$url);
return $supr;

This function utilizes the API and enables the short URLs to be created.

Now in your single.php add the following where you would like your short URL to be displayed:

$supr = getsupr(get_permalink($post->ID));
echo ‘here is a link: <a href="’.$supr.’">’.$supr.'</a>’

All done! Now each article on your blog will auto generate a short URL for you and your readers to share and also will benefit from the one click syndication that the service offers.

Using To Boost Your Visitors

Ever since using we have been treating it like another Twitter client and as a bonus its attracting a few extra visitors and this is how we do it.

Your first requirement is to have a Stumble Upon account, if not a quick registration is all it takes. Be sure to set it so when you submit a link it posts it straight to either your Twitter profile or Facebook Fan page.


I set to nenuno on Twitter and my fan page for nenuno instead of my personal Facebook account

Find the post you want to promote via and enter the URL in the Twitter like box.


Press “Just Shorten” which turns it into a short url which is shown in the tutorial above! Now style the post as you would on Twitter.


You can either schedule the post for another time or post it now. When posted, it will now be shown in your Facebook and Twitter timeline to all your followers and friends.


You will now be able to see how many times it gets clicked by your Stumble Upon friends. The flurry of visitors isn’t instant and can take time like any tools that promise increased traffic. But as an example, here are the statistics of a link we submitted yesterday.


** Note we are not promising a major traffic boost, we are simply sharing our experience with the service and hope it helps your project in some way!


  1. Thanks for the tut. I guess they have a plugin for WordPress too.

  2. This was really helpful! Thank you for all the great code sets.

  3. Hi Paul! I have been LOVING this awesome feature, but it suddenly stopped working after I upgraded to WordPress 3.1 today. Is there anything I can do to get it up and running again? To see an example on my blog, scroll down to the bottom of the post in the “Share” section and click on the Twitter bird. It used to display the short URL in a Twitter status, but now I just get an error. Thank you so much for your help!!

  4. I hear when you use a shortin url service like it actually helps your SERPS within the engines!

Leave a Reply

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