G
G
George2016-02-26 10:03:26
WordPress
George, 2016-02-26 10:03:26

How to display the total number of AddThis page likes in Wordpress?

AddThis has an open API for total page likes (the sum of the likes of all supported social networks).
It looks like this api-public.addthis.com/url/shares.json?url=http://...
How to display the total number of likes for a Wordpress page? As an example, I take the number of comments that is displayed out of the box.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
George, 2016-02-26
@georgypoplavsky

To display the number of likes for a particular page:

<?
$likes=json_decode(file_get_contents('http://api-public.addthis.com/url/shares.json?url=http://toster.ru/q/296028'));
?>
<?=$likes->shares;?></li>

To display the total number of likes for the page you are viewing:
<?
$likes=json_decode(file_get_contents('http://api-public.addthis.com/url/shares.json?url='.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']));
?>
<?=$likes->shares;?></li>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question