を行うことができ、簡単なPHPスクリプトを見つけることができますが、このコードが必要です。カウント共有ページについては
.share-button {
font-family: sans-serif;
display: inline-block;
padding: 7px 10px;
border: 1px solid #EEE;
border-radius: 3px;
background-color: #FAFAFA;
color: #656565;
text-decoration: none;
}
.share-button:hover {
border: 1px solid #999;
box-shadow: 0 2px 2px rgba(0, 0, 0, 0.1);
}
.share-button span {
display: inline-block;
margin-right: 10px;
color: red;
}
<a class="share-button" href="http://www.facebook.com/sharer/sharer.php?u=<?php echo get_permalink();?>&t=<?=urlencode(get_the_title());?>" target="_blank"><span id="share-facebook">0</span>Facebook</a>
<a class="share-button" href="http://www.twitter.com/intent/tweet?url=<?php echo get_permalink();?>&text=<?=urlencode(get_the_title());?>" target="_blank"><span id="share-twitter">0</span>Twitter</a>
<a class="share-button" href="http://plus.google.com/share?url=<?php echo get_permalink();?>" target="_blank"><span id="share-gplus">0</span>Google Plus</a>
、あなたは#シェア-のFacebookなどのように、APIキーを必要とし、それぞれにリターンを挿入...この議論Getting the Facebook like/share count for a given URL
上の共有を取得する方法の詳細を参照してください
APIキーをお持ちの場合は、要求を出して共有ページ番号を取得し、情報を持つオブジェクトを取得した後、divに追加します。
<script type="text/javascript">
facebookreturnobject = $.getJSON('https://graph.facebook.c...'); // see examples on discussion above
$('#share-facebook').text(facebookreturnobject.share.count);
</script>
TwitterとGoogle Plusで同じことをします。
コードでアクセストークンを公開する必要があるため、現在の数をJS経由でクライアント側で行う必要はありません。したがって、ユーザーがサイトにログインしてユーザーアクセストークンを使用できるようにしない限り、これはサーバー側で行う必要があります。さらに、すべてのページの読み込み時に実行するべきではありません。速度の制限をかなり早く乗り越えることができます。したがって、キャッシュのいくつかの形式も同様に実装する必要があります。 – CBroe