June 20, 2009

Automatically get tr.im urls for your blog posts




trimBefore, we showed you how to automatically get tinyurl’s on your WordPress blog. Well this time, I found a tutorial that will make your WordPress blog automatically generate tr.im url’s for your blog posts.

First to do this, add the following lines to your functions.php file:

function getTrimUrl($url) {
  $tinyurl = file_get_contents("http://api.tr.im/api/trim_simple?url=".$url);
  return $tinyurl;
}

Now, copy and paste the following code in your single.php file anywhere inside the loop:

<?php
$turl = getTrimUrl(get_permalink($post->ID));
echo 'Short Url for this post: <a href="'.$turl.'">'.$turl.'</a>'
?>

There you go! Your WordPress blog will now automatically generate tr.im URL’s.

Aweber Email Marketing

Related posts:

  1. How to add an “edit” link to all of your WordPress Posts
  2. How to hide portions of text to Google on your WordPress blog
  3. Display the total number of users of your WordPress blog
  4. How to Add the Author’s Gravatar in Posts


Previous Post and Next Post


Try HostGator Webhosting for 1 cent for the 1st Month Click here and enter "wordpress"

Leave a reply

* means field is required.

*

*