はてなブックマーク件数取得APIに新しいAPIが追加されたらしいので試してみた。
テーマの index.php とか single.php などの表示したい所に以下のコードを挿入する。
<a href="http://b.hatena.ne.jp/entry/<?php the_permalink() ?>"> <script type="text/javascript" src="http://api.b.st-hatena.com/entry.count?url=<?php the_permalink() ?>&callback=document.write"></script> users </a>
見た目にこだわりたい場合
はてなブックマークのような見た目にしたい場合は、strong タグをつけて、CSS を追加。
テーマのPHPファイルに追加
<strong class="hb_users"> <a href="http://b.hatena.ne.jp/entry/<?php the_permalink() ?>"> <script type="text/javascript" src="http://api.b.st-hatena.com/entry.count?url=<?php the_permalink() ?>&callback=document.write"></script> users </a> </strong>
スタイルシートに追加
strong.hb_users a:link, strong.hb_users a:hover, strong.hb_users a:visited { color: #F00 !important; background: #FCC !important; }