WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to add a VKontakte (pretty much the russian version of Facebook) "like" button to wordpress posts by placing it within the loop along with Twitter/Facebook "like/share" buttons. While this works fine on single posts, on the news overview with excerpt poss the button displays repeatedly on the first post and not on ANY other post.

I'm following these instructions: http://vk.com/developers.php?o=-17680044&p=Like&s=0

I know the issue has to be with something in the javascript messing with the loop and repeating it in one post instead of beneath EVERY post but no idea how to fix it.

Oddly enough their "share" button works absolutely fine.

Any help appreciated as all I so far was able to find about it was in russian...which I don't speak :/

share|improve this question
Where are you inserting that code? Also, check this search results in StackOverflow: stackoverflow.com/search?q=VKontakte – brasofilo Nov 20 '12 at 22:59

This isn't WordPress specific, but the code provided on the page you linked places a div with an ID and some javascript that references that ID. If you have multiple instances of this on a single page, you'll have multiple instances of divs and scripts using the same ID, and CSS IDs must be unique.

You can remedy this by adding the post ID to each instance to make them all unique:

<div id="vk_like_<?php echo get_the_ID(); ?>"></div>
<script type="text/javascript">
VK.Widgets.Like("vk_like_<?php echo get_the_ID(); ?>", {type: "full"});

However, this isn't all you'll need. If you read the text at the bottom of the page:

If the article on your site can have different addresses (for example, depending on the redirecting source, langauge, and other parameters), then in VK.Widgets.Like your internal page identifier 'page_id should be rendered as the last parameter. An example of a code with page_id can be found in the full widget documentation

you'll also need to set a page_id, otherwise all buttons will like the list of posts page rather than the single post page. I'm not able to see the documentation page without a login, so I can only guess that this parameter accepts a permalink.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.