Question

https://developers.facebook.com/docs/reference/plugins/share-links/

This site refers to a button in which people can share the site on Facebook. That's nice and it works obviously, but not in the way I want it to work. I am running a Wordpress site so I want to get all the comments' unique id's to show when I click on this button on a certain comment. The variable I made is working (I tested it on something else), but I can't get it work with this share button. Can someone show me how to do this?

So this is the snippet:

<a href="#" 
  onclick="
    window.open(
      'https://www.facebook.com/sharer/sharer.php?u='+encodeURIComponent(location.href), 
      'facebook-share-dialog', 
      'width=626,height=436'); 
    return false;">
  Share on Facebook
</a>

What I tried was replacing location.href and the whole encodeURI line, but that lead to nothing.

The variable I am trying to add is $testinglink

Edit:

The link I want to output is this: http://teteteststssst.com/baa/?p=6410&cpage=1#comment-1 ; in the pagetitle of the share dialog I am getting this, but not in the TITLE or BODY of the Share Dialog... How can this be?

Was it helpful?

Solution

Now it works. It was just adding a urlencode before the variable like this:

urlencode($testlink)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top