How to make a ‘share this post on Twitter’ link in WordPress

This tips applies to coding a WordPress theme design. You won’t be able to copy and paste the code straight into your posts. You will need full access to editing themes on your server (yes, I can host WordPress sites if you contact me).

Should produce valid HTML and work nicely, mostly the work of Jamie Huskisson and Herself’s Webtools. I added a quick change to produce completely valid HTML (I’m very fussy about that sort of thing).

<a href=”<?php echo urlencode(get_permalink(get_the_ID())); ?>&amp;title=<?php echo urlencode(get_the_title(get_the_ID())); ?>”> Share this on Twitter </a>

UPDATE: Twitter has changed it’s url format. This is the new format:

Share this:
Share this page via Email Share this page via Stumble Upon Share this page via Digg this Share this page via Facebook Share this page via Twitter

Leave a Comment