Support » Fixing WordPress » Facebook share button pulling wrong post

  • I’ve been trying to implement a Facebook share button (among others) on the header of every post on the home page. I’ve used the code specified on Facebook’s own site, and am feeding it the permalink for the post and the post title. I’ve viewed the source of the page and verified that these are correct.

    I’m also doing this in the header on single post pages.

    When I click the button on a single post, it works fine. However, when I click the button on a post on the index, Facebook inevitably pulls the wrong post into its share popup. I am not sure what is going on — I’ve added a meta title tag to the single post pages as Facebook suggests but it’s not helping. I think it’s never even loading the right page, and somehow attempting to share a post somewhere on the index page, but always the wrong one. I’m not sure how it would even detect to load the index page instead of the URL I feed it, since the fbs_click javascript isn’t that complicated:

    <!-- facebook -->
    function fbs_click() {
      u='<?= the_permalink() ?>';
      t='<?= trim(htmlspecialchars(the_title())) ?>';''+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
      return false;
    <a href="<?= urlencode(the_permalink()) ?>" onclick="return fbs_click()" target="_blank"><img class="iconistan-icon" src="" alt="Facebook" /></a>

    My only guess would be that Facebook is detecting the HTTP referrer and trying to pull data from that, and just ignoring what I give it for some reason.

Viewing 1 replies (of 1 total)
  • Oh, and FYI, I’d prefer not to use ShareThis for this if possible. I’m trying to do something pretty custom.

Viewing 1 replies (of 1 total)
  • The topic ‘Facebook share button pulling wrong post’ is closed to new replies.