Wednesday, July 17, 2013

WordPress function to show a total share counter (FB, Twitter, G+)

Simply paste the following function where you want your counter to appear:


 function social_shares() {
     $url = get_permalink( $post_id ); 
     $json = file_get_contents("http://api.sharedcount.com/?url=" .
 rawurlencode($url));
     $counts = json_decode($json, true);
     $totalcounts= $counts["Twitter"] + 
 $counts["Facebook"]["total_count"] +
 $counts["GooglePlusOne"];
     echo "<div>$totalcounts Share</div>";
 }
 

Thanks a lot to Davide for submitting this tip!

Source: http://www.wprecipes.com/wordpress-function-to-show-a-total-share-counter-fb-twitter-g

Jarvis Jones minnesota vikings Eric Reid Kyle Long UFC 159 aaron rodgers Lane Johnson

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.