June 20, 2009
Automatically get tr.im urls for your blog posts
Before, 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.
Related posts:
- Show latest posts in the sidebar
- How to add an “edit” link to all of your WordPress Posts
- Display the Author Who Edited a Post Last
- How to widgetize a WordPress blog theme
- How to hide portions of text to Google on your WordPress blog
Previous Post and Next Post













