I needed to get a unique url for each page and adapted a script that I found through the help of other members here.
One is for the like button and the other is for the comment box. Is there a more elegant way to do this without so much code?
<br>
<!-- start facebook like code-->
<div id="thelike"></div>
<script>
var thisurl = document.URL;
function changeCommentsUrl(newUrl){
// should refresh fb like plugin for the "newUrl" variable
document.getElementById('thelike').innerHTML='';
parser=document.getElementById('thelike');
parser.innerHTML='<div class="fb-like" data-href="'+newUrl+'" data-send="true" data-layout="button_count" data-width="400" data-show-faces="false"></div>';
FB.XFBML.parse(parser);
}
changeCommentsUrl(thisurl);
</script>
<!-- end facebook like code-->
<br>
<!-- start facebook comment code-->
<div id="thecomments"></div>
<script>
var thisurl = document.URL;
function changeCommentsUrl(newUrl){
// should refresh fb comments plugin for the "newUrl" variable
document.getElementById('thecomments').innerHTML='';
parser=document.getElementById('thecomments');
parser.innerHTML='<div class="fb-comments" data-href="'+newUrl+'" data-num-posts="10" data-width="400"></div>';
FB.XFBML.parse(parser);
}
changeCommentsUrl(thisurl);
</script>
<!-- end facebook coment code-->
<br>