Top 5 ways to Add URL Shortening Services on Your Blog


In recent years,The URL(Uniform Resource Locator) Shortening sites has gained more popularity because of the micro blogging site Twitter.We need Short URLs  for Twitter ,which has character limits.Many Short URL services such as such as ThinyURL,, are providing aliases for longer URLs and give redirection to them.In this Article I show you how integrate these URL shortening services in your blog.

Way #1:

Begin with a easy,You can use Word Press plugins to integrate those URL shortening services to your Blog.

URL Shortener plugin allows you to generate shortlinks for post/pages using URL Shortener Services such as,,, Digg and many others, it’s simple to implement and has many interesting features you can customize as you prefer.


Another  good URL Shortener Plugin is GentleSource Short URL. This plugin creates a short URL from the blog post permalink and stores it in the database. It supports,,, and


Third one  quite interesting plugin ShortURL. This WordPress plugin that allows you to use your blog as your own URL shorterning service by implementing the Short URL Auto-Discovery specification. Your short URLs will be in the form of http://domain/-code.


The next two methods are needed some basic coding skills.If you don’t know about it.I will explain in detail.

Now you can integrate in your WordPress theme.To do that, you need a Bitly account and an API key.

Than, you have to modify your WordPress theme and add this function into the function.php file:

function bitly($url) {
$content = file_get_contents("
$element = new SimpleXmlElement($content);
$bitly = $element->data->url;
echo $bitly;}
echo '0';

Then replace  YOURLOGIN with your user name and YOURAPIKEY with your API key of account.

In single.php add this code into the loop to return the shortened URL of the permalink of the current post:

<?php bitly(get_permalink($post->post_id)); ?>

A useful way to use this code snippet is to integrate it with Twitter’s status update link:

<a href="<?php the_title();?>
<?php bitly(get_permalink($post->post_id)); ?> RT @SpicyTricks" target="_blank">


Another interesting way to integrate an URL shortening service on your blog is using TinyURL. TinyURL doesn’t require an account and, unlike Bitly, doesn’t have a rate limit in the API calls.

If you want to integrate it with your WordPress theme add this function into function.php:

function thinyURL($url) {
$ch = curl_init();
$timeout = 5;
$data = curl_exec($ch);
echo $data;

Open single.php and add the following code into the loop to return the shortened URL of the permalink of the current post:

<?php thinyURL(get_permalink($post->post_id)); ?>

If you want to integrate it with a Twitter’s status update link use this code:

<a href="<?php the_title();?>
<?php thinyURL(get_permalink($post->post_id)); ?> RT @woork" target="_blank">


Use TinyURL in your WordPress theme. It’s faster than and doesn’t have limit rate for API calls.So that your site will  load significantly faster.

© 2023 . All rights reserved.
Follow Us On