2

Blogs hosted on wordpress.com get automatic link shortening via http://wp.me/, but for those who prefer to seek out our own hosting solution is there a plugin that will, upon publishing a new post/page, make an api call to bit.ly (or other such service) store the resulting url and return it from wp_get_shortlink()?

I have searched without success. Any help would be appreciated.

3 Answers 3

1

There's this plugin:

http://wordpress.org/extend/plugins/wp-bitly/

0
3

if you install the wordpress.com stats plugin on your self hosted wordpress blog, you will have the option to have wp.me shortlinks

1
1

You could also add something like this to your functions.php to add a short link (powered by tinyurl) to each post or page you have:

function shortLink($content) {
$url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$short_url = file_get_contents('http://tinyurl.com/api-create.php?url='.urlencode($url));

$content .=  '<div class="short-link">Here's a short link <a href=".$short_url.'">Short Link</a></div>';

return $content;

}

add_filter('the_content', 'shortLink');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.