How To Add Twitter’s “Official” Tweet Button to WordPress MU
Friday, August 13th, 2010
I don’t know yet whether this is an issue with our WordPress theme, with the Twitter Button plugin or with the service from Twitter itself. Stay tuned…
With Twitter releasing their new “Tweet Button” yesterday, I was naturally interested in figuring out how to add the button to this site. Mashable had the first post out that I saw explaining the easy steps: “HOW TO: Use Tweet Buttons as a Blogger or Site Owner“. In going to Twitter’s “Tweet Button” page, it’s a fairly straightforward process to get the code you need.
THE PLUGIN
However, I want to make system admin of this blog server as painless as possible so before I added the code to our theme I looked around for a plugin. I was delighted to see in the comments to the Mashable post that a gent named Alex Cristache had already coded up a “Twitter Button Plugin for WordPress” plugin.
I downloaded and installed it into the wp-contents/plugins and activated it for one of our blogs. (More on site-wide activation in a minute.) It has a very easy to use admin screen that appeared from a link at the bottom of my admin navbar. (Note: I’m still running WPMU 2.9.2 here, so with 3.0.x it may appear differently.) The panel lets me make various config choices. I left it all at the defaults except for three areas:

- I needed to change the Twitter user name to ours.
- I changed the recommended user (Alex, the plugin author
) to be one of our other Twitter accounts. This will apparently appear in the window from Twitter after you share the link,although it’s not doing so for me right now. (probably a load issue at Twitter):
- I changed the “margin-top” attribute in the CSS so that the Tweet button appeared in line with the top of the article text. This is a personal preference thing… and I like it this way.
With that, the tweet button was up and running on one of the blogs. I went on to test with another and all worked fine.
SITE-WIDE ACTIVATION
We support about a dozen active blogs on blogs.voxeo.com and I really didn’t want to have to go to each one to change around these defaults…. so I started hacking the code before doing the “Activate Site Wide” link.
Diving into wp-content/plugins/wp-twitter-button, I opened twitter-button.php and changed these lines:
function tb_activate() {
$default_settings = Array(
'tb_home' => 1,
'tb_archive' => 1,
'tb_feed' => 1,
'tb_page' => 1,
'tb_box' => 'vertical', // can be none, horizontal or vertical
'tb_style' => 'float: left; margin-right: 10px; margin-top: 20px;',
'tb_position' => 'before', // can be before or after
'tb_via' => 'Twitter',
'tb_recommended_id' => 'Blogsessive',
'tb_recommended_description' => 'Blogging, Social Media and ...'
);
to these lines (changes in red):
function tb_activate() {
$default_settings = Array(
'tb_home' => 1,
'tb_archive' => 1,
'tb_feed' => 1,
'tb_page' => 1,
'tb_box' => 'vertical', // can be none, horizontal or vertical
'tb_style' => 'float: left; margin-right: 10px; margin-top: 0px;',
'tb_position' => 'before', // can be before or after
'tb_via' => 'voxeo',
'tb_recommended_id' => 'tropo',
'tb_recommended_description' => 'Tropo is a powerful yet simple API ...'
);
(Note that I have not included the entire “recommended description” in this code example purely for space/layout reasons with this blog post. In the file I have the full descriptions.)
I then went ahead and clicked the “Activate Twitter Button for WordPress Site Wide” link on my Plugins panel and it worked fine.
THE END RESULT
I now have the official “Tweet” button working on my WPMU 2.9.2 install and it seems to be working fine. The issues I see so far:
1. TWEET COUNT IS OFF – It seems the big issue everyone has right now is that the count of the number of tweets is off a bit. Commenters to the Mashable post and to the WordPress plugin page both indicate this is a problem. The plugin author stated this:
That ZERO tweets “bug” is actually caused by Twitter’s method to calculate tweets. They calculate them based on the number of search results on Twitter for the shared URL, and since their search history doesn’t go that far behind, some of the posts will display 0. The API they have provided is still far from perfect, but I think they said the button is hosted on a different server which might mean that from now on, all counts will not depend on the search anymore so new posts should be fine.
2. WISH THE NUMBER WOULD NOT SHOW IF “0″ – Given that count issue, I wish there was the option to NOT display the count if the number of tweets is zero. It’s just a perception thing… I’d like to not show that a particular article hasn’t had an Twitter-love yet (particularly if it did have tweets and now doesn’t have a count as an artifact of Twitter’s problems) I intend to make the suggestion back to the plugin author… but this may be a Twitter issue.
3. DO RECOMMENDATIONS WORK? WHAT IF I ONLY WANT ONE? – So far when I’ve tweeted out a blog post using the button, I’ve not yet seen the “recommendations” screen that Twitter says we’ll see. Is Twitter not displaying it right now? Does it work? What if I don’t want to recommend a second account- do I just leave that field blank in the plugin panel?
Obviously before I can answer any of that I have to see recommendations.
Overall, though, it seems to be working great. Kudos to Alex Cristache for coming out with this plugin so quickly. It’s a great help and saved me from hacking away on my theme.
Anyone else found another way (or plugin) to do this? What have you found so far?
Want to learn how Voxeo can help unlock your communications and deliver a better customer experience? Please contact us!
If you found this post interesting or helpful, please consider either subscribing via RSS, becoming a fan on Facebook, or following us on Twitter.
What do you do if your company has multiple blog sites that you want to maintain as separate distinct sites with their own domains? You could, of course, install a separate instance of WordPress for each domain and run them on separate servers, etc. But if you have your nice shiny 


With DNS now pointing to your WPMU server, the final step is to configure your blog to respond to this new domain. In the WPMU dashboard for your blog, under the “Tools” menu, there is now a new “Domain Mapping” menu choice as shown in the screen capture on the right side.


Way back in late 2007 when I launched
One aspect I quite like about the plugin is the menu you get when you move your mouse over the source code. As shown in the image to right, you can easily:




RSS Feed




