Wordpress tinyurl plugin

I was in a quandary. I wanted the long permalinks for my blog posts,which made links self-describing and also search engine friendly. And I also wanted short URLs that I could pass on in emails. I share the sentiments of Andy Wibbels regarding TinyURL. Nothing against TinyURL personally, just that when you have your own domain name for your blog, wouldn’t you prefer using tiny urls using your own domain name?

So I extended the one liner by Andy Wibbels and created a real small plugin, to display the “tiny url” in your post.

To use it:

  1. Download it from here.
  2. Rename it to wptinyurl.php.
  3. Copy it into the wp-content/plugins directory in your WP root.
  4. Activate the plugin in your WP admin section.
  5. Then use the function wptinyurl() in your template files, wherever you want the tinyurl of the post to be displayed.

In my case, to display the tiny urls in my posts, I have added the following line just before edit_post_link() in the single.php file in the theme directory. The relevant section of the file in my case now looks like this:

By default, the code uses the prefix /bl/ for generating your tinyurls. So your typical tinyurls will be http://yourdomain/bl/nn, where nn is your post id.

To customize, edit the wptinyurl.php file, and change the variables as commented.

  1. Change $prefix from /bl/ to any other that you want. Just remember to keep the slashes at the beginning and the end of the string.
  2. Change $text to whichever template you want to use to print your tiny url. Just remember, to use %s wherever you want the tiny url to be substituted. If you use %s more or less than twice, remember to change the first printf function in the code accordingly.
  3. As an added feature, if you set the variable $print_rule to True in the code, the code will also provide you with the .htaccess rule that you require to make the tinyurl work. The rule will be inside an HTML comment. You can simply copy-paste from the HTML source of the page and add it at the end of the .htaccess file in your domain web root. You can set this variable to false after you have configured your .htaccess file.

That’s it.

Biting the “broadband” bullet again - Tata Broadband in Delhi Wordpress XML-RPC bug and 1.5.1.3 Upgrade patch