Integrating Twitter with WordPress is pretty easy to do without a plugin. With a few lines of code you can have a nice tweet this or follow me button on every post or page of your WordPress website.

However, the URL that is part of the Tweet is the permalink URL and for many sites you’ll want to Tweet a shortened URL. If like me, using Bit.ly and Yoast’s Bitly Shortlink plugin, you maybe wondering how to get your short Bit.ly URL to be part of your tweet.

Joost kindly stores the bitty short URL in custom post meta field so all you have to do is retrieve it and show it on the page

<a href="https://twitter.com/share" class="twitter-share-button" data-url="<?php echo get\_post\_meta($id, '\_yoast\_bitlylink', true); ?>" data-counturl=<?php echo get_permalink(); ?> data-count="horizontal" data-via="damiensaunders" rel="me">Tweet</a><script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>

Linkage

Yoast Bit.ly Shortlinks