---
title: How to Add Shortlink Support to Twitter Tools
date: 2011-01-12T17:43:43+00:00
modified: 2011-01-12T20:38:19+00:00
permalink: https://kaspars.net/blog/how-to-add-shortlink-support-to-twitter-tools
post_type: post
author:
  name: Kaspars
  avatar: https://reverse.kaspars.net/gravatar/avatar/92bfcd3a8c3a21a033a6484d32c25a40b113ec6891f674336081513d5c98ef76?s=96&d=mm&r=g
post_tag:
  - How to
  - Plugin
category:
  - WordPress
---

# How to Add Shortlink Support to Twitter Tools

By default the [Twitter Tools plugin](http://wordpress.org/extend/plugins/twitter-tools/) uses URLs such as `http://example.com/p=123` in your tweets. However, if you are using one of the [URL shortener plugins](http://wordpress.org/extend/plugins/tags/url-shortener) (that make use of the standard [get\_shortlink()](http://core.trac.wordpress.org/browser/tags/3.0.4/wp-includes/link-template.php#L2176) function), chances are that you would rather include the URL generated by that plugin. To do that, simply add this to your theme’s `functions.php`:

```
add_filter('tweet_blog_post_url', 'get_shortlink_for_twitter');
function get_shortlink_for_twitter($url) {
	return wp_get_shortlink(url_to_postid($url));
}
```