Yesterday, Twitter launched their official button for websites and keen-eyed observers will have noticed that markwilson.it now sports a shiny new “tweet” icon at the head of each post.Â It’s pretty easy to do (Twitter generates the code for you – and has an FAQ for developers) but there may be a couple of things to watch out for, depending on your blog’s content management system.
I use self-hosted WordPress, and these were the changes I made to the site:
- For my single posts, I just added the Twitter-generated code to an appropriate position in the single.php file.
- For my main index page, I edited index.php, but didn’t want the generated link to be to the current page (my home page with several recent posts) – I wanted it to relate to the particular post that the viewer is tweeting from.Â Adapting a tip from David Teng, I added two parameters to the link code (
Now, by clicking the Tweet button on this post, the link generated relates to the post – and not the home page for the blog.