Create short URL’s to your WordPress blog posts (with link to PHP code)

This is a very simple hint for those who have at least a minimum amount of knowledge about PHP programming. is a service to create short URLs. For example, it allows you to replace a very long URL such as into a very short URL like Both URLs lead to the same internet page.

It is incredibly easy to add a small button to your WordPress blog to create short URLs to your blog post. Such a button makes it much easier for your readers to copy a URL to include it in their e-mails, chat sessions and Facebook pages. Here’s how to do it.

WordPress’ source code consists of PHP files, containing a mixture of JavaScript, plain HTML and PHP. Just find the right place in WordPress’ PHP files. You will want to put the button either in a sidebar or in a footer.
Now insert the following line, which is a combination of HTML and PHP, into the location of your choice (unfortuantely, I have to insert the code as a picture because Posterous doesn’t allow for including any html syntax in a blog post):


For your convenience, there is a file with the same code available here.

That’s all! Now you can just click the little button on your WordPress blog and will let you create the short URL to your blog post right-away.

Leave a Reply

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