The new official Tweet This button has been launched, though setting up wasn’t as straightforward as we thought it would be and there are still one or two issues for us.
Most people, I expect, will go here for the easiest way to get the code:
Here, you can select:
- Tweet Text (either the page title or something you decide on)
- URL to tweet (the page the URL is on, or one of your choice)
- Recommend people to follow
And once you have done this, you are presented with the code you should implement on your web page – however, this is static code that won’t work correctly if you place it within the Wordpress blog post layout.
For example, the code for taking the page title and URL you are on looks like:
We found that placing this within each blog post in the index.php file means that when you visit, for example:
The Tweet now button within each post will actually tweet the above URL and page title “Digital Marketing Blog”.
Instead, the following iframe code can be used to get the permalink and correct page title:
<iframe allowtransparency="true" frameborder="0" scrolling="no" src="http://platform.twitter.com/widgets/tweet_button.html?url=<?php echo urlencode(get_permalink($post->ID)); ?>&via=returnondigital&text=<?php the_title(); ?>&count=horizontal" style="width:110px;height:20px;"></iframe>
The only issue that remains, which was also apparent with Tweetmeme, is that it doesn’t archive too far back when viewing details of who has tweeted the page. For example, it tells us that 5 people Tweeted our recent blog post:
21-07-10: Google Looking Pretty In Pink
But when we click for more details, there are none:
Other than that, it’s good to go.