How to count retweets in full text on your WordPress posts

The first thing to do is to open your functions.php file and insert the following function:

function tweetCount($url) { $content = file_get_contents("http://api.tweetmeme.com/url_info?url=".$url); $element = new SimpleXmlElement($content); $retweets = $element->story->url_count; if($retweets){ return $retweets; } else { return 0; }}

Once done, open your single.php file and paste the following:

$rt = tweetCount(get_permalink());echo "Retweeted ".$rt." times.";

Source


View the original article here


This post was made using the Auto Blogging Software from WebMagnates.org This line will not appear when posts are made after activating the software to full version.

0 comments:

Post a Comment