1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Make Facebook Share button pull Post URL

Discussion in 'General Programming Chat' started by Scorpion Ghost, Feb 12, 2014.

  1. Scorpion Ghost

    Scorpion Ghost Senior Member

    Joined:
    Mar 22, 2013
    Messages:
    865
    Likes Received:
    171
    Hey guys, i have a small issue i need some help with.

    On a Humor blog i got i have share buttons appearing below every post (Twitter, Google+, FB Like, FB Share). And they appear both on the Homepage (multi-post pages) and on Individual Post Pages.

    The first three work perfectly, but the Facebook Share button, when it's clicked from the homepage instead of pulling the Post URL to share it, it pulls the Homepage URL.

    Now, i remember having an issue on how to make it open in a popup instead of a new tab, i solved that. But now i have this problem.

    Here is the code i am using:

    Code:
    <a href='#' onclick=' window.open(&apos;https://www.facebook.com/sharer/sharer.php?u=&apos;+encodeURIComponent(location.href), &apos;facebook-share-dialog&apos;, &apos;width=626,height=436&apos;); return false;'>
    <img class='nopin' src='http://1.bp.blogspot.com/-qsSzRNmHCtQ/Uikm54x4k4I/AAAAAAAAAYA/okhjT_nCIyI/s1600/Facebook+Share+Button.png'/>
    </a> </div>
    So how can i make the button - when it's clicked on the homepage - pull the Post's URL and Description instead of the Homepage's one???

    I am working on a Blogger Blog with this.

    By the way, here is the Twitter part of the code, maybe it will help you figure out how i can do it:

    Code:
    <a class='twitter-share-button' data-count='horizontal' data-lang='en' data-related='Name' data-via='Name' expr:data-text='data:post.title' expr:data-url='data:post.url' href='https://twitter.com/share'>Tweet</a></div>
    I'm pretty sure it has something to do with the href='#' part and the (location.href) part from the Facebook's code, but i don't know how to fix it so that it does what i want... I did try fixing it before asking here, but i didn't manage to solve it...

    Thanks.
     
  2. Scorpion Ghost

    Scorpion Ghost Senior Member

    Joined:
    Mar 22, 2013
    Messages:
    865
    Likes Received:
    171
    Bumping this...