
Twitter is obviously a very useful tools for bloggers. Did you ever wanted to know how many times your posts are sent to Twitter by your readers? If yes, just read on and learn how to know it, and display it on your blog, in full text mode.

Twitter is obviously a very useful tools for bloggers. Did you ever wanted to know how many times your posts are sent to Twitter by your readers? If yes, just read on and learn how to know it, and display it on your blog, in full text mode.
paste the following function in your functions.php file:
<?php
function tweets($url){
$content = file_get_contents("http://api.tweetmeme.com/url_info?url=".$url);
$x = new SimpleXmlElement($content);
$tweets = $x->story->url_count;
echo "Tweets: ".$tweets;
}
Once done, you can get the number of tweets for any web page you want, for exemple:
<?php tweets("http://www.wprecipes.com"); ?>
To automatically display how many times your posts has been tweet, open the single.php file file and paste the following code:
<?php tweets($post->permalink); ?>
18 Responses
Cool tip bro !
Great tip again! You are doing a great job
can I do it while the twitter plugin on?
I didn’t realised that is so easy. Great recipe again!
exactly what I was searching for !!! Thank you for that great piece of code.
Wow, this one gets a bit technical, nice one, though.
Nice tutorial, thank you!
Sounded complicated, but it’s really quite simple. Thanks.
That really is very simple to use. I’m always looking for ways to reduce the number of plugins in my blog. I’m going to try this one!
I am using this tip right now to my own blog
Thanks
Is it code that exactly look like on the bottom on your post? Included bit.ly short url?
stupid question, does this go in the theme functions or the wordpress functions page?
Does it work only with Wordpress blogs? Would it work if I pasted it into a regular website? Just wondering if it’s WP-exclusive.
@Kotlina: You can use that tip anywhere on a php page, not only WP blogs
Twitter is obviously sweeping the country for both social and friendly outlets and business opportunities. This is a pretty sweet recipe for the blogger and twitter user
of course it is a bit more technical, but worth it.
Till then,
Jean
Thanks for the snippet. Its pretty cool
I was unable to get the changes in single page working due to this line:
$post->permalink
I had to replace that with
get_permalink()
And it worked great !
thanks again!
-dee
So if you send more than 150 API request per hour, by the end of the hour you’ll get no answer as the of call is limited
A caching system would be very much appreciated
Trackbacks: